diff --git a/README.md b/README.md index 2e545c44..42fd812b 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ An implementation of the [JSON-LD 1.1](https://www.w3.org/TR/json-ld/) (JSON-bas The goals of Titanium are: - conformance to the specification -- secure, stable, fast, A+ code +- secure, stable, fast, A+ code (1700 tests) - minimal external dependencies - only `jakarta.json-api` is required - simple to use diff --git a/src/main/java/com/apicatalog/jsonld/uri/UriResolver.java b/src/main/java/com/apicatalog/jsonld/uri/UriResolver.java index f6c91392..e60b771c 100644 --- a/src/main/java/com/apicatalog/jsonld/uri/UriResolver.java +++ b/src/main/java/com/apicatalog/jsonld/uri/UriResolver.java @@ -149,7 +149,7 @@ private static final String[] resolveAsComponents(final URI base, final URI rela } else { target[2] = basePath; - if (UriUtils.isDefined(relative.getQuery())) { + if (relative.getQuery() != null) { target[3] = relative.getQuery(); } else { @@ -175,7 +175,7 @@ private static final String[] resolveAsComponents(final URI base, final URI rela */ private static final String removeDotSegments(final String path) { - if (UriUtils.isNotDefined(path)) { + if (path == null) { return null; } @@ -244,7 +244,7 @@ private static final String removeDotSegments(final String path) { */ private static final String merge(String basePath, String path) { - if (UriUtils.isNotDefined(basePath)) { + if (basePath == null) { return "/".concat(path); } diff --git a/src/main/java/com/apicatalog/jsonld/uri/UriUtils.java b/src/main/java/com/apicatalog/jsonld/uri/UriUtils.java index 0c9d2f3d..851a3701 100644 --- a/src/main/java/com/apicatalog/jsonld/uri/UriUtils.java +++ b/src/main/java/com/apicatalog/jsonld/uri/UriUtils.java @@ -164,7 +164,7 @@ protected static final String recompose(final String scheme, final String author final StringBuilder builder = new StringBuilder(); - if (isDefined(scheme)) { + if (scheme != null) { builder.append(scheme); builder.append(":"); } @@ -172,26 +172,17 @@ protected static final String recompose(final String scheme, final String author builder.append("//"); builder.append(authority); } - if (isDefined(path)) { + if (path != null) { builder.append(path); } - if (isDefined(query)) { + if (query != null) { builder.append('?'); builder.append(query); } - if (isDefined(fragment)) { + if (fragment != null) { builder.append('#'); builder.append(fragment); } return builder.toString(); } - - protected static final boolean isDefined(final String value) { - return value != null && StringUtils.isNotBlank(value); - } - - protected static final boolean isNotDefined(final String value) { - return value == null || StringUtils.isBlank(value); - } - } diff --git a/src/test/resources/com/apicatalog/jsonld/test/issue310-in.json b/src/test/resources/com/apicatalog/jsonld/test/issue310-in.json new file mode 100644 index 00000000..53f95a22 --- /dev/null +++ b/src/test/resources/com/apicatalog/jsonld/test/issue310-in.json @@ -0,0 +1,10 @@ +{ + "@context": { + "@version": 1.1, + "@base": "http://example/document", + "@vocab": "#" + }, + "@id": "http://example.org/places#BrewEats", + "@type": "Restaurant", + "name": "Brew Eats" +} \ No newline at end of file diff --git a/src/test/resources/com/apicatalog/jsonld/test/issue310-out.json b/src/test/resources/com/apicatalog/jsonld/test/issue310-out.json new file mode 100644 index 00000000..f60c7da0 --- /dev/null +++ b/src/test/resources/com/apicatalog/jsonld/test/issue310-out.json @@ -0,0 +1,13 @@ +[ + { + "@id": "http://example.org/places#BrewEats", + "@type": [ + "http://example/document#Restaurant" + ], + "http://example/document#name": [ + { + "@value": "Brew Eats" + } + ] + } +] \ No newline at end of file diff --git a/src/test/resources/com/apicatalog/jsonld/test/manifest.json b/src/test/resources/com/apicatalog/jsonld/test/manifest.json index 723080ee..6b0e2845 100644 --- a/src/test/resources/com/apicatalog/jsonld/test/manifest.json +++ b/src/test/resources/com/apicatalog/jsonld/test/manifest.json @@ -139,6 +139,13 @@ "expect": "issue257-2-out.json", "frame": "issue257-2-frame.json", "option": { "omitGraph" : false } + }, + { + "@id": "#t0017", + "@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"], + "name": "Issue #310: # as vocabulary mapping", + "input": "issue310-in.json", + "expect": "issue310-out.json" } ] }