0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-30 22:34:10 -05:00

Merge pull request #1409 from verdaccio/fix-1400

fix: allows pkg names that starts with dash
This commit is contained in:
Juan Picado @jotadeveloper 2019-07-28 23:11:03 +02:00 committed by GitHub
commit e35d8d99db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View file

@ -57,11 +57,20 @@ export function validateName(name: string): boolean {
const normalizedName: string = name.toLowerCase();
// all URL-safe characters and "@" for issue #75
/**
* Some context about the first regex
* - npm used to have a different tarball naming system.
* eg: http://registry.npmjs.com/thirty-two
* https://registry.npmjs.org/thirty-two/-/thirty-two@0.0.1.tgz
* The file name thirty-two@0.0.1.tgz, the version and the pkg name was separated by an at (@)
* while nowadays the naming system is based in dashes
* https://registry.npmjs.org/verdaccio/-/verdaccio-1.4.0.tgz
*
* more info here: https://github.com/rlidwka/sinopia/issues/75
*/
return !(
!normalizedName.match(/^[-a-zA-Z0-9_.!~*'()@]+$/) ||
normalizedName.charAt(0) === '.' || // ".bin", etc.
normalizedName.charAt(0) === '-' || // "-" is reserved by couchdb
normalizedName === 'node_modules' ||
normalizedName === '__proto__' ||
normalizedName === 'favicon.ico'

View file

@ -246,6 +246,8 @@ describe('Utilities', () => {
expect(validateName('verdaccio')).toBeTruthy();
expect(validateName('some.weird.package-zzz')).toBeTruthy();
expect(validateName('old-package@0.1.2.tgz')).toBeTruthy();
// fix https://github.com/verdaccio/verdaccio/issues/1400
expect(validateName('-build-infra')).toBeTruthy();
});
test('should be valid using uppercase', () => {