Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/issue 310 #317

Merged
merged 2 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/apicatalog/jsonld/uri/UriResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
}

Expand Down Expand Up @@ -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);
}

Expand Down
17 changes: 4 additions & 13 deletions src/main/java/com/apicatalog/jsonld/uri/UriUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,34 +164,25 @@ 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(":");
}
if (authority != null) {
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);
}

}
10 changes: 10 additions & 0 deletions src/test/resources/com/apicatalog/jsonld/test/issue310-in.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"@context": {
"@version": 1.1,
"@base": "http://example/document",
"@vocab": "#"
},
"@id": "http://example.org/places#BrewEats",
"@type": "Restaurant",
"name": "Brew Eats"
}
13 changes: 13 additions & 0 deletions src/test/resources/com/apicatalog/jsonld/test/issue310-out.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[
{
"@id": "http://example.org/places#BrewEats",
"@type": [
"http://example/document#Restaurant"
],
"http://example/document#name": [
{
"@value": "Brew Eats"
}
]
}
]
7 changes: 7 additions & 0 deletions src/test/resources/com/apicatalog/jsonld/test/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
}
Loading