Skip to content

Commit 8f3d4fe

Browse files
authored
Merge pull request #264 from rzukowski/issue255
Handling JSONPointer (URI fragment identifier) with no base uri
2 parents fde3a1c + e4686dd commit 8f3d4fe

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/main/java/com/networknt/schema/JsonSchema.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ private URI combineCurrentUriWithIds(URI currentUri, JsonNode schemaNode) {
8282
final String id = validationContext.resolveSchemaId(schemaNode);
8383
if (id == null) {
8484
return currentUri;
85+
} else if (isUriFragmentWithNoContext(currentUri, id)) {
86+
return null;
8587
} else {
8688
try {
8789
return this.validationContext.getURIFactory().create(currentUri, id);
@@ -90,6 +92,10 @@ private URI combineCurrentUriWithIds(URI currentUri, JsonNode schemaNode) {
9092
}
9193
}
9294
}
95+
96+
private boolean isUriFragmentWithNoContext(URI currentUri, String id) {
97+
return id.startsWith("#") && currentUri == null;
98+
}
9399

94100
public URI getCurrentUri()
95101
{

0 commit comments

Comments
 (0)