Skip to content

Commit

Permalink
Check for absolutes
Browse files Browse the repository at this point in the history
  • Loading branch information
stkenny committed Nov 21, 2020
1 parent 6dec89a commit 3ac6ebc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main/java/org/deri/grefine/rdf/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class Util {
private static final String XSD_DOUBLE_URI = "http://www.w3.org/2001/XMLSchema#double";
private static final String XSD_DATE_URI = "http://www.w3.org/2001/XMLSchema#date";

private static final String[] PREFIXES = { "http://", "https://", "file://", "ftp://" };

public static String resolveUri(URI base, String rel) {
try {
URI relUri = new URI(rel);
Expand All @@ -31,7 +33,10 @@ public static String resolveUri(URI base, String rel) {
}
} catch (URISyntaxException e) {
String testRel = rel.toLowerCase();
if (testRel.startsWith("http://") || testRel.startsWith("https://") || testRel.startsWith("ftp://")) {
if (testRel.matches("(" + PREFIXES[0] + "|"
+ PREFIXES[1] + "|"
+ PREFIXES[2] + "|"
+ PREFIXES[3] + ").*")) {
return "error:" + e.toString();
}
}
Expand Down

0 comments on commit 3ac6ebc

Please sign in to comment.