Don't check package name when parsing

This commit is contained in:
Michael Jackson
2018-05-25 20:30:53 -04:00
parent c0e0f899d2
commit bca5722eae
2 changed files with 2 additions and 10 deletions

View File

@ -1,7 +1,5 @@
const url = require("url");
const isValidPackageName = require("./isValidPackageName");
const packageURLFormat = /^\/((?:@[^/@]+\/)?[^/@]+)(?:@([^/]+))?(\/.*)?$/;
function decodeParam(param) {
@ -18,7 +16,6 @@ function decodeParam(param) {
function parsePackageURL(originalURL) {
const { pathname, search, query } = url.parse(originalURL, true);
const match = packageURLFormat.exec(pathname);
// Disallow invalid URL formats.
@ -27,12 +24,6 @@ function parsePackageURL(originalURL) {
}
const packageName = match[1];
// Disallow invalid npm package names.
if (!isValidPackageName(packageName)) {
return null;
}
const packageVersion = decodeParam(match[2]) || "latest";
const filename = decodeParam(match[3]);