Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSF3: Remove path from autoTitle browser code #17185

Merged
merged 2 commits into from Jan 10, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/store/src/autoTitle.ts
@@ -1,5 +1,4 @@
import startCase from 'lodash/startCase';
import path from 'path';
import slash from 'slash';

// FIXME: types duplicated type from `core-common', to be
Expand Down Expand Up @@ -36,7 +35,9 @@ export const autoTitleFromSpecifier = (fileName: string, entry: NormalizedStorie

if (importPathMatcher.exec(normalizedFileName)) {
const suffix = normalizedFileName.replace(directory, '');
const titleAndSuffix = slash(path.join(titlePrefix, suffix));
const slashes = new RegExp('/{1,}', 'g');
// Do not use path to join the parts, since this runs in the browser
const titleAndSuffix = slash([titlePrefix, suffix].join('/').replace(slashes, '/'));
IanVS marked this conversation as resolved.
Show resolved Hide resolved
return startCaseTitle(stripExtension(titleAndSuffix));
}
return undefined;
Expand Down