-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(model): Rework purl conversion according to the specs
Implement the pseudo-algorithm described at [1]. Most importantly, '/' in namespaces are now not escaped anymore (also see the lengthy discussion at [2]), key names are lower-cased, and qualifiers are sorted for comparability. [1]: https://github.com/package-url/purl-spec/blob/master/PURL-SPECIFICATION.rst#how-to-build-purl-string-from-its-components [2]: package-url/purl-spec#176 Signed-off-by: Sebastian Schuberth <[email protected]>
- Loading branch information
1 parent
23fc4e2
commit 8715de4
Showing
3 changed files
with
36 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,10 +68,10 @@ class PurlExtensionsTest : WordSpec({ | |
purl shouldBe "pkg:generic/name@version" | ||
} | ||
|
||
"percent-encode namespaces with segments" { | ||
val purl = Identifier("generic", "name/space", "name", "version").toPurl() | ||
"percent-encode namespace segments" { | ||
val purl = Identifier("generic", "name space/with spaces", "name", "version").toPurl() | ||
|
||
purl shouldBe "pkg:generic/name%2Fspace/name@version" | ||
purl shouldBe "pkg:generic/name%20space/with%20spaces/name@version" | ||
} | ||
|
||
"percent-encode the name" { | ||
|
@@ -104,8 +104,8 @@ class PurlExtensionsTest : WordSpec({ | |
val purl = id.toPurl(extras.qualifiers, extras.subpath) | ||
|
||
purl shouldBe "pkg:maven/com.example/[email protected]?" + | ||
"download_url=https%3A%2F%2Fexample.com%2Fsources.zip&" + | ||
"checksum=md5%3Addce269a1e3d054cae349621c198dd52" | ||
"checksum=md5%3Addce269a1e3d054cae349621c198dd52&" + | ||
"download_url=https%3A%2F%2Fexample.com%2Fsources.zip" | ||
purl.toProvenance() shouldBe provenance | ||
} | ||
|
||
|
@@ -125,10 +125,10 @@ class PurlExtensionsTest : WordSpec({ | |
val purl = id.toPurl(extras.qualifiers, extras.subpath) | ||
|
||
purl shouldBe "pkg:maven/com.example/[email protected]?" + | ||
"vcs_type=Git&" + | ||
"vcs_url=https%3A%2F%2Fgithub.com%2Fapache%2Fcommons-text.git&" + | ||
"resolved_revision=7643b12421100d29fd2b78053e77bcb04a251b2e&" + | ||
"vcs_revision=7643b12421100d29fd2b78053e77bcb04a251b2e&" + | ||
"resolved_revision=7643b12421100d29fd2b78053e77bcb04a251b2e" + | ||
"vcs_type=Git&" + | ||
"vcs_url=https%3A%2F%2Fgithub.com%2Fapache%2Fcommons-text.git" + | ||
"#subpath" | ||
purl.toProvenance() shouldBe provenance | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters