diff --git a/lib/core-client/package.json b/lib/core-client/package.json index fa2ad7e5e71e..255395ffb8b8 100644 --- a/lib/core-client/package.json +++ b/lib/core-client/package.json @@ -54,7 +54,7 @@ "lodash": "^4.17.20", "qs": "^6.10.0", "regenerator-runtime": "^0.13.7", - "slash": "^4.0.0", + "slash": "^3.0.0", "ts-dedent": "^2.0.0", "unfetch": "^4.2.0", "util-deprecate": "^1.0.2" diff --git a/lib/core-client/src/preview/autoTitle.test.ts b/lib/core-client/src/preview/autoTitle.test.ts index baa197de4599..2efc491b9239 100644 --- a/lib/core-client/src/preview/autoTitle.test.ts +++ b/lib/core-client/src/preview/autoTitle.test.ts @@ -50,7 +50,7 @@ describe('autoTitle', () => { it('match with windows path', () => { expect( - auto('/path/to_my/file', { glob: '', specifier: { directory: '.\\path' } }) + auto('/path/to_my/file', { glob: '', specifier: { directory: '\\path' } }) ).toMatchInlineSnapshot(`To My/File`); }); }); @@ -94,7 +94,7 @@ describe('autoTitle', () => { it('match with windows path', () => { expect( - auto('/path/to_my/file', { glob: '', specifier: { directory: '.\\path\\' } }) + auto('/path/to_my/file', { glob: '', specifier: { directory: '\\path\\' } }) ).toMatchInlineSnapshot(`To My/File`); }); }); diff --git a/lib/core-client/src/preview/autoTitle.ts b/lib/core-client/src/preview/autoTitle.ts index 1f04ee4da5c3..b5a98a93b28b 100644 --- a/lib/core-client/src/preview/autoTitle.ts +++ b/lib/core-client/src/preview/autoTitle.ts @@ -35,12 +35,13 @@ export const autoTitleFromEntry = (fileName: string, entry: NormalizedStoriesEnt const { directory, titlePrefix = '' } = entry.specifier || {}; // On Windows, backslashes are used in paths, which can cause problems here // slash makes sure we always handle paths with unix-style forward slash - const normalizedDirectory = slash(directory); + const normalizedDirectory = directory && slash(directory); const normalizedFileName = slash(fileName); if (normalizedFileName.startsWith(normalizedDirectory)) { const suffix = normalizedFileName.replace(normalizedDirectory, ''); - return startCaseTitle(stripExtension(path.join(titlePrefix, suffix))); + const titleAndSuffix = slash(path.join(titlePrefix, suffix)); + return startCaseTitle(stripExtension(titleAndSuffix)); } return undefined; }; diff --git a/lib/core-common/src/utils/es6Transpiler.ts b/lib/core-common/src/utils/es6Transpiler.ts index 70efb4c442fb..c1e679bd2e3d 100644 --- a/lib/core-common/src/utils/es6Transpiler.ts +++ b/lib/core-common/src/utils/es6Transpiler.ts @@ -9,12 +9,11 @@ const nodeModulesThatNeedToBeParsedBecauseTheyExposeES6 = [ 'node_modules/highlight.js', 'node_modules/json5', 'node_modules/semver', - 'node_modules/slash', ]; export const es6Transpiler: () => RuleSetRule = () => { // TODO: generate regexp using are-you-es5 - + console.log('es6Transpiler'); const include = (input: string) => { return ( !!nodeModulesThatNeedToBeParsedBecauseTheyExposeES6.find((p) => input.includes(p)) || diff --git a/yarn.lock b/yarn.lock index 8f9cc768a9ca..a0055d13ff4b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6897,7 +6897,7 @@ __metadata: lodash: ^4.17.20 qs: ^6.10.0 regenerator-runtime: ^0.13.7 - slash: ^4.0.0 + slash: ^3.0.0 ts-dedent: ^2.0.0 unfetch: ^4.2.0 util-deprecate: ^1.0.2 @@ -39038,13 +39038,6 @@ resolve@1.19.0: languageName: node linkType: hard -"slash@npm:^4.0.0": - version: 4.0.0 - resolution: "slash@npm:4.0.0" - checksum: b522ca75d80d107fd30d29df0549a7b2537c83c4c4ecd12cd7d4ea6c8aaca2ab17ada002e7a1d78a9d736a0261509f26ea5b489082ee443a3a810586ef8eff18 - languageName: node - linkType: hard - "slice-ansi@npm:0.0.4": version: 0.0.4 resolution: "slice-ansi@npm:0.0.4"