diff --git a/src/ui/ui_exports/ui_export_types/style_sheet_paths.js b/src/ui/ui_exports/ui_export_types/style_sheet_paths.js index a5e25a300696a76..81644a494288a13 100644 --- a/src/ui/ui_exports/ui_export_types/style_sheet_paths.js +++ b/src/ui/ui_exports/ui_export_types/style_sheet_paths.js @@ -25,7 +25,7 @@ const OK_EXTNAMES = ['.css', '.scss']; function normalize(localPath, type, pluginSpec) { const pluginId = pluginSpec.getId(); - const publicDir = pluginSpec.getPublicDir(); + const publicDir = path.normalize(pluginSpec.getPublicDir()); const extname = path.extname(localPath); if (!OK_EXTNAMES.includes(extname)) { diff --git a/src/ui/ui_exports/ui_export_types/style_sheet_paths.test.js b/src/ui/ui_exports/ui_export_types/style_sheet_paths.test.js index 7fa7fec412b4450..d95ae7816c4cf6c 100644 --- a/src/ui/ui_exports/ui_export_types/style_sheet_paths.test.js +++ b/src/ui/ui_exports/ui_export_types/style_sheet_paths.test.js @@ -21,18 +21,18 @@ import { styleSheetPaths } from './style_sheet_paths'; describe('uiExports.styleSheetPaths', () => { const pluginSpec = { - getId: () => 'test', - getPublicDir: () => '/kibana/public' + getId: jest.fn(() => 'test'), + getPublicDir: jest.fn(() => '/kibana/public') }; it('does not support relative paths', () => { expect(() => styleSheetPaths([], 'public/bar.css', 'styleSheetPaths', pluginSpec)) - .toThrowError('[plugin:test] uiExports.styleSheetPaths must be an absolute path, got "public/bar.css"'); + .toThrowError(/\[plugin:test\] uiExports.styleSheetPaths must be an absolute path/); }); it('path must be child of public path', () => { expect(() => styleSheetPaths([], '/another/public/bar.css', 'styleSheetPaths', pluginSpec)) - .toThrowError('[plugin:test] uiExports.styleSheetPaths must be child of publicDir [/kibana/public]'); + .toThrowError(/\[plugin:test\] uiExports.styleSheetPaths must be child of publicDir/); }); it('only supports css or scss extensions', () => { @@ -57,4 +57,15 @@ describe('uiExports.styleSheetPaths', () => { expect(uiExports.styleSheetPaths[0].localPath).toEqual(localPath); expect(uiExports.styleSheetPaths[0].publicPath).toEqual('plugins/test/bar.css'); }); + + it('should normalize the path for Windows', () => { + pluginSpec.getPublicDir.mockReturnValue('\\kibana\\public'); + + const localPath = '\\kibana/public/bar.css'; + const uiExports = styleSheetPaths([], localPath, 'styleSheetPaths', pluginSpec); + + expect(uiExports.styleSheetPaths).toHaveLength(1); + expect(uiExports.styleSheetPaths[0].localPath).toEqual(localPath); + expect(uiExports.styleSheetPaths[0].publicPath).toEqual('plugins/test/bar.css'); + }); }); \ No newline at end of file