Skip to content

Commit 7596a6f

Browse files
Fix incorrect purl with multiple forward slashes in namespace (#31)
* Fix incorrect purl with multiple forward slashes in namespace Signed-off-by: Agustin Isasmendi <[email protected]>
1 parent 8146ad5 commit 7596a6f

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "packageurl-js",
3-
"version": "0.0.6",
3+
"version": "0.0.7",
44
"description": "JavaScript library to parse and build \"purl\" aka. package URLs. This is a microlibrary implementing the purl spec at https://github.com/package-url",
55
"main": "index.js",
66
"scripts": {

src/package-url.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ class PackageURL {
7070
if (this.namespace) {
7171
purl.push(
7272
encodeURIComponent(this.namespace)
73-
.replace('%3A', ':')
74-
.replace('%2F', '/')
73+
.replace(/%3A/g, ':')
74+
.replace(/%2F/g, '/')
7575
);
7676
purl.push('/');
7777
}

test/data/test-suite-data.json

+12
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,18 @@
5959
"subpath": null,
6060
"is_invalid": false
6161
},
62+
{
63+
"description": "valid go purl with namespace that has more than one forward slash",
64+
"purl": "pkg:golang/github.com/cncf/xds/[email protected]",
65+
"canonical_purl": "pkg:golang/github.com/cncf/xds/[email protected]",
66+
"type": "golang",
67+
"namespace": "github.com/cncf/xds",
68+
"name": "go",
69+
"version": "v0.0.0-20210922020428-25de7278fc84",
70+
"qualifiers": null,
71+
"subpath": null,
72+
"is_invalid": false
73+
},
6274
{
6375
"description": "bitbucket namespace and name should be lowercased",
6476
"purl": "pkg:bitbucket/birKenfeld/pyGments-main@244fd47e07d1014f0aed9c",

0 commit comments

Comments
 (0)