Skip to content

Commit

Permalink
Merge pull request #264 from rzukowski/issue255
Browse files Browse the repository at this point in the history
Handling JSONPointer (URI fragment identifier) with no base uri
  • Loading branch information
stevehu committed Mar 9, 2020
2 parents fde3a1c + e4686dd commit 8f3d4fe
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main/java/com/networknt/schema/JsonSchema.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ private URI combineCurrentUriWithIds(URI currentUri, JsonNode schemaNode) {
final String id = validationContext.resolveSchemaId(schemaNode);
if (id == null) {
return currentUri;
} else if (isUriFragmentWithNoContext(currentUri, id)) {
return null;
} else {
try {
return this.validationContext.getURIFactory().create(currentUri, id);
Expand All @@ -90,6 +92,10 @@ private URI combineCurrentUriWithIds(URI currentUri, JsonNode schemaNode) {
}
}
}

private boolean isUriFragmentWithNoContext(URI currentUri, String id) {
return id.startsWith("#") && currentUri == null;
}

public URI getCurrentUri()
{
Expand Down

0 comments on commit 8f3d4fe

Please sign in to comment.