GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Ignore @base if remote context is not relative · jsonld-java/jsonld-java@45c2942

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • core/src
    • main/java/com/github/jsonldjava/core
      • Context.java
    • test/java/com/github/jsonldjava/core
      • DocumentLoaderTest.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎core/src/main/java/com/github/jsonldjava/core/Context.java‎

Copy file name to clipboardExpand all lines: core/src/main/java/com/github/jsonldjava/core/Context.java
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,11 @@ private Context parse(Object localContext, List<String> remoteContexts,
187187
}
188188
// 3.2)
189189
else if (context instanceof String) {
190-
String uri = (String) result.get(JsonLdConsts.BASE);
190+
String uri = null;
191+
// @base is ignored when processing remote contexts, https://github.com/jsonld-java/jsonld-java/issues/304
192+
if (!context.toString().matches("^[hH][tT][tT][pP][sS]?://.*")) {
193+
uri = (String) result.get(JsonLdConsts.BASE);
194+
}
191195
uri = JsonLdUrl.resolve(uri, (String) context);
192196
// 3.2.2
193197
if (remoteContexts.contains(uri)) {
Collapse file

‎core/src/test/java/com/github/jsonldjava/core/DocumentLoaderTest.java‎

Copy file name to clipboardExpand all lines: core/src/test/java/com/github/jsonldjava/core/DocumentLoaderTest.java
+10-2Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,11 +381,19 @@ public void testDisallowRemoteContexts() throws Exception {
381381
}
382382

383383
@Test
384-
public void injectContext() throws Exception {
384+
public void testInjectContext() throws Exception {
385+
injectContext(new JsonLdOptions());
386+
}
387+
388+
@Test
389+
public void testIssue304_remoteContextAndBaseIri() throws Exception {
390+
injectContext(new JsonLdOptions("testing:baseIri"));
391+
}
392+
393+
private void injectContext(final JsonLdOptions options) throws Exception {
385394

386395
final Object jsonObject = JsonUtils.fromString(
387396
"{ \"@context\":\"http://nonexisting.example.com/thing\", \"pony\":5 }");
388-
final JsonLdOptions options = new JsonLdOptions();
389397

390398
// Verify fails to find context by default
391399
try {

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.