Allow slashes in purl package names

This commit is contained in:
Justin Holguín
2024-05-02 19:07:02 +00:00
committed by GitHub
parent 0c155c5e85
commit 432d8e7efe
4 changed files with 37 additions and 4 deletions

View File

@@ -46,7 +46,10 @@ export function parsePURL(purl: string): PackageURL {
namePlusRest = parts[1]
} else {
result.namespace = decodeURIComponent(parts[1])
namePlusRest = parts[2]
// Add back the '/'s to the rest of the parts, in case there are any more.
// This may violate the purl spec, but people do it and it can be parsed
// without ambiguity.
namePlusRest = parts.slice(2).join('/')
}
const name = namePlusRest.match(/([^@#?]+)[@#?]?.*/)
if (!result.namespace && !name) {