updating dist
This commit is contained in:
+21
-1
@@ -25029,6 +25029,12 @@ class PackageURL {
|
|||||||
_handlePyPi() {
|
_handlePyPi() {
|
||||||
this.name = this.name.toLowerCase().replace(/_/g, '-');
|
this.name = this.name.toLowerCase().replace(/_/g, '-');
|
||||||
}
|
}
|
||||||
|
_handlePub() {
|
||||||
|
this.name = this.name.toLowerCase();
|
||||||
|
if (!/^[a-z0-9_]+$/i.test(this.name)) {
|
||||||
|
throw new Error('Invalid purl: contains an illegal character.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
toString() {
|
toString() {
|
||||||
var purl = ['pkg:', encodeURIComponent(this.type), '/'];
|
var purl = ['pkg:', encodeURIComponent(this.type), '/'];
|
||||||
@@ -25036,6 +25042,9 @@ class PackageURL {
|
|||||||
if (this.type === 'pypi') {
|
if (this.type === 'pypi') {
|
||||||
this._handlePyPi();
|
this._handlePyPi();
|
||||||
}
|
}
|
||||||
|
if (this.type === 'pub') {
|
||||||
|
this._handlePub();
|
||||||
|
}
|
||||||
|
|
||||||
if (this.namespace) {
|
if (this.namespace) {
|
||||||
purl.push(
|
purl.push(
|
||||||
@@ -25128,7 +25137,18 @@ class PackageURL {
|
|||||||
let version = null;
|
let version = null;
|
||||||
if (path.includes('@')) {
|
if (path.includes('@')) {
|
||||||
let index = path.indexOf('@');
|
let index = path.indexOf('@');
|
||||||
version = decodeURIComponent(path.substring(index + 1));
|
let rawVersion= path.substring(index + 1);
|
||||||
|
version = decodeURIComponent(rawVersion);
|
||||||
|
|
||||||
|
// Convert percent-encoded colons (:) back, to stay in line with the `toString`
|
||||||
|
// implementation of this library.
|
||||||
|
// https://github.com/package-url/packageurl-js/blob/58026c86978c6e356e5e07f29ecfdccbf8829918/src/package-url.js#L98C10-L98C10
|
||||||
|
let versionEncoded = encodeURIComponent(version).replace(/%3A/g, ':');
|
||||||
|
|
||||||
|
if (rawVersion !== versionEncoded) {
|
||||||
|
throw new Error('Invalid purl: version must be percent-encoded');
|
||||||
|
}
|
||||||
|
|
||||||
remainder = path.substring(0, index);
|
remainder = path.substring(0, index);
|
||||||
} else {
|
} else {
|
||||||
remainder = path;
|
remainder = path;
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user