Skip to content

Commit

Permalink
fix: slug string conflict with scope
Browse files Browse the repository at this point in the history
  • Loading branch information
xsbchen committed Feb 2, 2024
1 parent 943a9f0 commit 2028879
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/yarnpkg-core/sources/structUtils.ts
Expand Up @@ -665,7 +665,7 @@ export function stringifyLocator(locator: Locator) {
*/
export function slugifyIdent(ident: Ident) {
if (ident.scope !== null) {
return `@${ident.scope}-${ident.name}`;
return `@${ident.scope}_${ident.name}`;
} else {
return ident.name;
}
Expand Down
13 changes: 13 additions & 0 deletions packages/yarnpkg-core/tests/structUtils.test.ts
@@ -0,0 +1,13 @@
import * as structUtils from '../sources/structUtils';

describe(`structUtils`, () => {
describe(`slugifyIdent`, () => {
it(`should return a unique slug string with scope`, () => {
const slugA = structUtils.slugifyIdent({scope: `myscope`, name: `user-email`});

Check failure on line 6 in packages/yarnpkg-core/tests/structUtils.test.ts

View workflow job for this annotation

GitHub Actions / Testing chores

Argument of type '{ scope: string; name: string; }' is not assignable to parameter of type 'Ident'.
expect(slugA).toEqual(`@myscope_user-email`);
const slugB = structUtils.slugifyIdent({scope: `myscope-user`, name: `email`});

Check failure on line 8 in packages/yarnpkg-core/tests/structUtils.test.ts

View workflow job for this annotation

GitHub Actions / Testing chores

Argument of type '{ scope: string; name: string; }' is not assignable to parameter of type 'Ident'.
expect(slugB).toEqual(`@myscope-user_email`);
expect(slugA).not.toEqual(slugB);
});
});
});

0 comments on commit 2028879

Please sign in to comment.