@@ -38755,11 +38755,20 @@ var require_package_url2 = __commonJS({
38755
38755
_handlePyPi() {
38756
38756
this.name = this.name.toLowerCase().replace(/_/g, "-");
38757
38757
}
38758
+ _handlePub() {
38759
+ this.name = this.name.toLowerCase();
38760
+ if (!/^[a-z0-9_]+$/i.test(this.name)) {
38761
+ throw new Error("Invalid purl: contains an illegal character.");
38762
+ }
38763
+ }
38758
38764
toString() {
38759
38765
var purl = ["pkg:", encodeURIComponent(this.type), "/"];
38760
38766
if (this.type === "pypi") {
38761
38767
this._handlePyPi();
38762
38768
}
38769
+ if (this.type === "pub") {
38770
+ this._handlePub();
38771
+ }
38763
38772
if (this.namespace) {
38764
38773
purl.push(
38765
38774
encodeURIComponent(this.namespace).replace(/%3A/g, ":").replace(/%2F/g, "/")
@@ -38769,7 +38778,7 @@ var require_package_url2 = __commonJS({
38769
38778
purl.push(encodeURIComponent(this.name).replace(/%3A/g, ":"));
38770
38779
if (this.version) {
38771
38780
purl.push("@");
38772
- purl.push(encodeURIComponent(this.version).replace(/%3A/g, ":"));
38781
+ purl.push(encodeURIComponent(this.version).replace(/%3A/g, ":").replace(/%2B/g, "+") );
38773
38782
}
38774
38783
if (this.qualifiers) {
38775
38784
purl.push("?");
@@ -38792,7 +38801,8 @@ var require_package_url2 = __commonJS({
38792
38801
if (!purl || typeof purl !== "string" || !purl.trim()) {
38793
38802
throw new Error("A purl string argument is required.");
38794
38803
}
38795
- let [scheme, remainder] = purl.split(":", 2);
38804
+ let scheme = purl.slice(0, purl.indexOf(":"));
38805
+ let remainder = purl.slice(purl.indexOf(":") + 1);
38796
38806
if (scheme !== "pkg") {
38797
38807
throw new Error('purl is missing the required "pkg" scheme component.');
38798
38808
}
@@ -38825,7 +38835,7 @@ var require_package_url2 = __commonJS({
38825
38835
let index = path.indexOf("@");
38826
38836
let rawVersion = path.substring(index + 1);
38827
38837
version2 = decodeURIComponent(rawVersion);
38828
- let versionEncoded = encodeURIComponent(version2).replace(/%3A/g, ":");
38838
+ let versionEncoded = encodeURIComponent(version2).replace(/%3A/g, ":").replace(/%2B/g, "+") ;
38829
38839
if (rawVersion !== versionEncoded) {
38830
38840
throw new Error("Invalid purl: version must be percent-encoded");
38831
38841
}
0 commit comments