Skip to content

Commit 1229f73

Browse files
committed
Fix missing trim(); simplify value parsing
See #292 (comment) and #292 (comment).
1 parent 1d675d7 commit 1229f73

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,13 +391,14 @@ private static URL alternateLink(URL url, CloseableHttpResponse response)
391391
boolean relAlternate = false;
392392
boolean jsonld = false;
393393
for (String value : header.getValue().split(";")) {
394-
if (value.trim().startsWith("<")) {
395-
alternateLink = value.replaceAll("<(.*)>", "$1");
394+
value=value.trim();
395+
if (value.startsWith("<") && value.endsWith(">")) {
396+
alternateLink = value.substring(1, value.length() - 1);
396397
}
397-
if (value.trim().startsWith("type=\"application/ld+json\"")) {
398+
if (value.startsWith("type=\"application/ld+json\"")) {
398399
jsonld = true;
399400
}
400-
if (value.trim().startsWith("rel=\"alternate\"")) {
401+
if (value.startsWith("rel=\"alternate\"")) {
401402
relAlternate = true;
402403
}
403404
}

0 commit comments

Comments
 (0)