Skip to content

Commit 80a6e84

Browse files
committed
fix: strip @ prefix if present
1 parent de872d3 commit 80a6e84

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

app/utils/npm.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
* Constructs a scope:team string in the format expected by npm.
33
* npm operations require the format @scope:team (with @ prefix).
44
*
5-
* @param orgName - The organization name (without @)
5+
* @param orgName - The organization name (with or without @)
66
* @param teamName - The team name
77
* @returns The scope:team string in @scope:team format
88
*/
99
export function buildScopeTeam(orgName: string, teamName: string): string {
10-
return `@${orgName}:${teamName}`
10+
return `@${orgName.replace(/^@/, '')}:${teamName}`
1111
}

test/unit/npm-utils.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ describe('buildScopeTeam', () => {
99
expect(buildScopeTeam('nuxt', 'core')).toBe('@nuxt:core')
1010
})
1111

12+
it('strips existing @ prefix from orgName', () => {
13+
expect(buildScopeTeam('@netlify', 'developers')).toBe('@netlify:developers')
14+
expect(buildScopeTeam('@nuxt', 'core')).toBe('@nuxt:core')
15+
})
16+
1217
it('produces format accepted by validateScopeTeam', () => {
1318
expect(() => validateScopeTeam(buildScopeTeam('netlify', 'developers'))).not.toThrow()
1419
expect(() => validateScopeTeam(buildScopeTeam('nuxt', 'core'))).not.toThrow()

0 commit comments

Comments
 (0)