Skip to content

Commit 6cb7290

Browse files
committed
Add test data
1 parent 050ad9f commit 6cb7290

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/main/java/com/github/packageurl/PackageURL.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ private String validateSubpath(final String value) throws MalformedPackageURLExc
412412
return validatePath(value.split("/"), true);
413413
}
414414

415-
private static boolean shouldKeepSegment(String segment, boolean isSubpath) {
415+
private static boolean shouldKeepSegment(final String segment, final boolean isSubpath) {
416416
return (!isSubpath || (!segment.isEmpty() && !".".equals(segment) && !"..".equals(segment)));
417417
}
418418

src/test/resources/test-suite-data.json

+24
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,30 @@
4747
"subpath": "googleapis/api/annotations",
4848
"is_invalid": false
4949
},
50+
{
51+
"description": "invalid subpath - unencoded subpath cannot contain '..'",
52+
"purl": "pkg:GOLANG/google.golang.org/genproto@abcdedf#/googleapis/%2E%2E/api/annotations/",
53+
"canonical_purl": "pkg:golang/google.golang.org/genproto@abcdedf#googleapis/api/annotations",
54+
"type": "golang",
55+
"namespace": "google.golang.org",
56+
"name": "genproto",
57+
"version": "abcdedf",
58+
"qualifiers": null,
59+
"subpath": "googleapis/api/annotations",
60+
"is_invalid": false
61+
},
62+
{
63+
"description": "invalid subpath - unencoded subpath cannot contain '.'",
64+
"purl": "pkg:GOLANG/google.golang.org/genproto@abcdedf#/googleapis/%2E/api/annotations/",
65+
"canonical_purl": "pkg:golang/google.golang.org/genproto@abcdedf#googleapis/api/annotations",
66+
"type": "golang",
67+
"namespace": "google.golang.org",
68+
"name": "genproto",
69+
"version": "abcdedf",
70+
"qualifiers": null,
71+
"subpath": "googleapis/api/annotations",
72+
"is_invalid": false
73+
},
5074
{
5175
"description": "bitbucket namespace and name should be lowercased",
5276
"purl": "pkg:bitbucket/birKenfeld/pyGments-main@244fd47e07d1014f0aed9c",

0 commit comments

Comments
 (0)