Skip to content

Commit a1cf279

Browse files
committed
Fix naming.
1 parent 8475ad4 commit a1cf279

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -436,18 +436,18 @@ private String canonicalize(boolean coordinatesOnly) {
436436
purl.append("/");
437437
}
438438
if (name != null) {
439-
purl.append(percentEncode(name));
439+
purl.append(uriEncode(name));
440440
}
441441
if (version != null) {
442-
purl.append("@").append(percentEncode(version));
442+
purl.append("@").append(uriEncode(version));
443443
}
444444
if (! coordinatesOnly) {
445445
if (qualifiers != null && !qualifiers.isEmpty()) {
446446
purl.append("?");
447447
qualifiers.entrySet().stream().forEachOrdered(entry -> {
448448
purl.append(toLowerCase(entry.getKey()));
449449
purl.append("=");
450-
purl.append(percentEncode(entry.getValue()));
450+
purl.append(uriEncode(entry.getValue()));
451451
purl.append("&");
452452
});
453453
purl.setLength(purl.length() - 1);
@@ -459,7 +459,7 @@ private String canonicalize(boolean coordinatesOnly) {
459459
return purl.toString();
460460
}
461461

462-
private static String percentEncode(final String source) {
462+
private static String uriEncode(final String source) {
463463
if (source == null || source.isEmpty()) {
464464
return source;
465465
}
@@ -560,7 +560,7 @@ private static String toLowerCase(String s) {
560560
return new String(chars);
561561
}
562562

563-
public static String percentDecode(final String source) {
563+
public static String uriDecode(final String source) {
564564
if (source == null || source.isEmpty()) {
565565
return source;
566566
}
@@ -661,16 +661,16 @@ private void parse(final String purl) throws MalformedPackageURLException {
661661
// version is optional - check for existence
662662
index = remainder.lastIndexOf('@');
663663
if (index >= start) {
664-
this.version = validateVersion(percentDecode(remainder.substring(index + 1)));
664+
this.version = validateVersion(uriDecode(remainder.substring(index + 1)));
665665
remainder = remainder.substring(0, index);
666666
}
667667

668668
// The 'remainder' should now consist of an optional namespace and the name
669669
index = remainder.lastIndexOf('/');
670670
if (index <= start) {
671-
this.name = validateName(percentDecode(remainder.substring(start)));
671+
this.name = validateName(uriDecode(remainder.substring(start)));
672672
} else {
673-
this.name = validateName(percentDecode(remainder.substring(index + 1)));
673+
this.name = validateName(uriDecode(remainder.substring(index + 1)));
674674
remainder = remainder.substring(0, index);
675675
this.namespace = validateNamespace(parsePath(remainder.substring(start), false));
676676
}
@@ -721,7 +721,7 @@ private Map<String, String> parseQualifiers(final String encodedString) throws M
721721
final String[] entry = value.split("=", 2);
722722
if (entry.length == 2 && !entry[1].isEmpty()) {
723723
String key = toLowerCase(entry[0]);
724-
if (map.put(key, percentDecode(entry[1])) != null) {
724+
if (map.put(key, uriDecode(entry[1])) != null) {
725725
throw new ValidationException("Duplicate package qualifier encountered. More then one value was specified for " + key);
726726
}
727727
}
@@ -740,12 +740,12 @@ private String[] parsePath(final String value, final boolean isSubpath) {
740740
}
741741
return PATH_SPLITTER.splitAsStream(value)
742742
.filter(segment -> !segment.isEmpty() && !(isSubpath && (".".equals(segment) || "..".equals(segment))))
743-
.map(segment -> percentDecode(segment))
743+
.map(segment -> uriDecode(segment))
744744
.toArray(String[]::new);
745745
}
746746

747747
private String encodePath(final String path) {
748-
return Arrays.stream(path.split("/")).map(segment -> percentEncode(segment)).collect(Collectors.joining("/"));
748+
return Arrays.stream(path.split("/")).map(segment -> uriEncode(segment)).collect(Collectors.joining("/"));
749749
}
750750

751751
/**

0 commit comments

Comments
 (0)