diff options
author | Gar <gar+gh@danger.computer> | 2022-03-29 23:35:34 +0300 |
---|---|---|
committer | Luke Karrys <luke@lukekarrys.com> | 2022-03-30 09:50:31 +0300 |
commit | 5b4cbb2175bfa35e347fe94e21d49a05ea64ead1 (patch) | |
tree | a626599980954d30d8293d48c65f343c35ce43b5 /node_modules/validate-npm-package-name/index.js | |
parent | 86eff5dccb9bce2eb8d80706e8dea855faf753b3 (diff) |
deps: validate-npm-package-name@4.0.0
* use latest builtins
Diffstat (limited to 'node_modules/validate-npm-package-name/index.js')
-rw-r--r-- | node_modules/validate-npm-package-name/index.js | 105 |
1 files changed, 0 insertions, 105 deletions
diff --git a/node_modules/validate-npm-package-name/index.js b/node_modules/validate-npm-package-name/index.js deleted file mode 100644 index eb43fa25e..000000000 --- a/node_modules/validate-npm-package-name/index.js +++ /dev/null @@ -1,105 +0,0 @@ -'use strict' - -var scopedPackagePattern = new RegExp('^(?:@([^/]+?)[/])?([^/]+?)$') -var builtins = require('builtins') -var blacklist = [ - 'node_modules', - 'favicon.ico' -] - -var validate = module.exports = function (name) { - var warnings = [] - var errors = [] - - if (name === null) { - errors.push('name cannot be null') - return done(warnings, errors) - } - - if (name === undefined) { - errors.push('name cannot be undefined') - return done(warnings, errors) - } - - if (typeof name !== 'string') { - errors.push('name must be a string') - return done(warnings, errors) - } - - if (!name.length) { - errors.push('name length must be greater than zero') - } - - if (name.match(/^\./)) { - errors.push('name cannot start with a period') - } - - if (name.match(/^_/)) { - errors.push('name cannot start with an underscore') - } - - if (name.trim() !== name) { - errors.push('name cannot contain leading or trailing spaces') - } - - // No funny business - blacklist.forEach(function (blacklistedName) { - if (name.toLowerCase() === blacklistedName) { - errors.push(blacklistedName + ' is a blacklisted name') - } - }) - - // Generate warnings for stuff that used to be allowed - - // core module names like http, events, util, etc - builtins.forEach(function (builtin) { - if (name.toLowerCase() === builtin) { - warnings.push(builtin + ' is a core module name') - } - }) - - // really-long-package-names-------------------------------such--length-----many---wow - // the thisisareallyreallylongpackagenameitshouldpublishdowenowhavealimittothelengthofpackagenames-poch. - if (name.length > 214) { - warnings.push('name can no longer contain more than 214 characters') - } - - // mIxeD CaSe nAMEs - if (name.toLowerCase() !== name) { - warnings.push('name can no longer contain capital letters') - } - - if (/[~'!()*]/.test(name.split('/').slice(-1)[0])) { - warnings.push('name can no longer contain special characters ("~\'!()*")') - } - - if (encodeURIComponent(name) !== name) { - // Maybe it's a scoped package name, like @user/package - var nameMatch = name.match(scopedPackagePattern) - if (nameMatch) { - var user = nameMatch[1] - var pkg = nameMatch[2] - if (encodeURIComponent(user) === user && encodeURIComponent(pkg) === pkg) { - return done(warnings, errors) - } - } - - errors.push('name can only contain URL-friendly characters') - } - - return done(warnings, errors) -} - -validate.scopedPackagePattern = scopedPackagePattern - -var done = function (warnings, errors) { - var result = { - validForNewPackages: errors.length === 0 && warnings.length === 0, - validForOldPackages: errors.length === 0, - warnings: warnings, - errors: errors - } - if (!result.warnings.length) delete result.warnings - if (!result.errors.length) delete result.errors - return result -} |