Skip to content

Commit

Permalink
fix: Fix the name validation of a package tarball (verdaccio#2242)
Browse files Browse the repository at this point in the history
Co-authored-by: Juan Picado <[email protected]>
  • Loading branch information
leometzger and juanpicado authored May 15, 2021
1 parent 2924ffa commit d2c65da
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/gold-vans-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@verdaccio/utils': patch
---

Fixed the validation of the name when searching for a tarball that have scoped package name
8 changes: 7 additions & 1 deletion packages/utils/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@ export function validateName(name: string): boolean {
if (_.isString(name) === false) {
return false;
}
let normalizedName: string = name.toLowerCase();

const normalizedName: string = name.toLowerCase();
const isScoped: boolean = name.startsWith('@') && name.includes('/');
const scopedName = name.split('/', 2)[1];

if (isScoped && !_.isUndefined(scopedName)) {
normalizedName = scopedName.toLowerCase();
}

/**
* Some context about the first regex
Expand Down
1 change: 1 addition & 0 deletions packages/utils/test/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ describe('Utilities', () => {
expect(validateName('[email protected]')).toBeTruthy();
// fix https://github.com/verdaccio/verdaccio/issues/1400
expect(validateName('-build-infra')).toBeTruthy();
expect(validateName('@pkg-scoped/without-extension')).toBeTruthy();
});

test('should be valid using uppercase', () => {
Expand Down

0 comments on commit d2c65da

Please sign in to comment.