Skip to content

Commit

Permalink
Merge branch 'package-url:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
aniruth37 authored Nov 3, 2023
2 parents fc13904 + a98c7fb commit 2c3e90e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Run Unit Tests
on:
pull_request:
branches:
- '**'
jobs:
unit_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: |
npm ci
npm run test
4 changes: 2 additions & 2 deletions src/package-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class PackageURL {

if (this.version) {
purl.push('@');
purl.push(encodeURIComponent(this.version).replace(/%3A/g, ':'));
purl.push(encodeURIComponent(this.version).replace(/%3A/g, ':').replace(/%2B/g,'+'));
}

if (this.qualifiers) {
Expand Down Expand Up @@ -189,7 +189,7 @@ class PackageURL {
// 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, ':');
let versionEncoded = encodeURIComponent(version).replace(/%3A/g, ':').replace(/%2B/g,'+');

if (rawVersion !== versionEncoded) {
throw new Error('Invalid purl: version must be percent-encoded');
Expand Down
12 changes: 12 additions & 0 deletions test/data/test-suite-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,18 @@
"subpath": null,
"is_invalid": false
},
{
"description": "debian can have debian versions as part of version with plus sign",
"purl": "pkg:deb/debian/[email protected]+deb10u3?arch=amd64&distro=debian-10",
"canonical_purl": "pkg:deb/debian/[email protected]+deb10u3?arch=amd64&distro=debian-10",
"type": "deb",
"namespace": "debian",
"name": "libssl1.1",
"version": "1.1.1n-0+deb10u3",
"qualifiers": {"arch": "amd64", "distro": "debian-10"},
"subpath": null,
"is_invalid": false
},
{
"description": "docker uses qualifiers and hash image id as versions",
"purl": "pkg:docker/customer/dockerimage@sha256:244fd47e07d1004f0aed9c?repository_url=gcr.io",
Expand Down

0 comments on commit 2c3e90e

Please sign in to comment.