diff --git a/index.html b/index.html index 7164c0c5..c46ee130 100644 --- a/index.html +++ b/index.html @@ -5809,7 +5809,7 @@

LoadDocumentCallback

  1. Create a new {{Promise}} promise and return it. The following steps are then executed asynchronously.
  2. -
  3. Set document to the body retrieved from +
  4. Set document to the body retrieved from the resource identified by url, or by otherwise locating a resource associated with url. When requesting remote documents the request MUST prefer Content-Type application/ld+json @@ -5824,10 +5824,17 @@

    LoadDocumentCallback

  5. Set documentUrl to the location of the retrieved resource considering redirections (exclusive of HTTP status 303 "See Other" redirects as discussed in [[?cooluris]]).
  6. +
  7. If the retrieved resource's Content-Type is not application/json + nor any media type with a +json suffix as defined in [[RFC6839]], + and the response has an HTTP Link Header [[RFC8288]] using the alternate link relation + with type `application/ld+json`, + set url to the associated href relative to the previous url + and restart the algorithm from step 2, + ensuring that documentUrl is set to the original url.
  8. If the retrieved resource's Content-Type is application/json or any media type with a +json suffix as defined in [[RFC6839]] except application/ld+json, - and the response has an HTTP Link Header [[RFC8259]] using the http://www.w3.org/ns/json-ld#context link relation, + and the response has an HTTP Link Header [[RFC8288]] using the http://www.w3.org/ns/json-ld#context link relation, set contextUrl to the associated href.

    If multiple HTTP Link Headers using the http://www.w3.org/ns/json-ld#context link relation are found, the promise is rejected with a JsonLdError whose code is set to multiple context link headers @@ -5972,7 +5979,7 @@

    RemoteDocument

    contextUrl
    -
    If available, the value of the HTTP Link Header [[RFC8259]] +
    If available, the value of the HTTP Link Header [[RFC8288]] using the http://www.w3.org/ns/json-ld#context link relation in the response. If the response's Content-Type is application/ld+json, @@ -6190,7 +6197,7 @@

    JsonLdErrorCode

    loading remote context failed
    There was a problem encountered loading a remote context.
    multiple context link headers
    -
    Multiple HTTP Link Headers [[RFC8259]] +
    Multiple HTTP Link Headers [[RFC8288]] using the http://www.w3.org/ns/json-ld#context link relation have been detected.
    processing mode conflict
    @@ -6372,6 +6379,9 @@

    Changes since JSON-LD Community Group Final Report

    a context. When this is set, vocabulary-relative IRIs, such as the entries of node objects, are expanded or compacted relative to the base IRI and the vocabulary mapping using string concatenation.
  9. +
  10. In the LoadDocumentCallback, if the retrieved content is not any JSON media type + and there is a link header with `rel=alternate` and `type=application/ld+json`, redirect + to that content.
  11. diff --git a/tests/remote-doc-manifest.jsonld b/tests/remote-doc-manifest.jsonld index d2086514..261f1dd7 100644 --- a/tests/remote-doc-manifest.jsonld +++ b/tests/remote-doc-manifest.jsonld @@ -134,6 +134,56 @@ }, "input": "remote-doc/0013-in.json", "expect": "remote-doc/0013-out.jsonld" + }, { + "@id": "#tla01", + "@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"], + "name": "Redirects if type is text/html", + "purpose": "Load an alternate link if type is not ld+json and rel=alternate.", + "option": { + "httpLink": "; rel=\"alternate\"; type=\"application/ld+json\"" + }, + "input": "remote-doc/la01-in.html", + "expect": "remote-doc/la01-out.jsonld" + }, { + "@id": "#tla02", + "@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"], + "name": "Does not redirect if type is application/ld+json", + "purpose": "Load an alternate link if type is not ld+json and rel=alternate.", + "option": { + "httpLink": "; rel=\"alternate\"; type=\"application/ld+json\"" + }, + "input": "remote-doc/la02-in.jsonld", + "expect": "remote-doc/la02-out.jsonld" + }, { + "@id": "#tla03", + "@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"], + "name": "Does not redirect if link type is not application/ld+json", + "purpose": "Load an alternate link if type is not ld+json and rel=alternate.", + "option": { + "httpLink": "; rel=\"alternate\"; type=\"application/json\"" + }, + "input": "remote-doc/la03-in.json", + "expect": "remote-doc/la03-out.jsonld" + }, { + "@id": "#tla04", + "@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"], + "name": "Does not redirect if type is application/json", + "purpose": "Load an alternate link if type is not ld+json and rel=alternate.", + "option": { + "httpLink": "; rel=\"alternate\"; type=\"application/ld+json\"" + }, + "input": "remote-doc/la04-in.json", + "expect": "remote-doc/la04-out.jsonld" + }, { + "@id": "#tla05", + "@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"], + "name": "Base remains that of original document", + "purpose": "Load an alternate link if type is not ld+json and rel=alternate.", + "option": { + "httpLink": "; rel=\"alternate\"; type=\"application/ld+json\"" + }, + "input": "remote-doc/la05-in.html", + "expect": "remote-doc/la05-out.jsonld" } ] } diff --git a/tests/remote-doc/la01-alternate.jsonld b/tests/remote-doc/la01-alternate.jsonld new file mode 100644 index 00000000..672295e9 --- /dev/null +++ b/tests/remote-doc/la01-alternate.jsonld @@ -0,0 +1,6 @@ +{ + "@context": { + "@vocab": "http://example.org/" + }, + "content": "alternate" +} \ No newline at end of file diff --git a/tests/remote-doc/la01-in.html b/tests/remote-doc/la01-in.html new file mode 100644 index 00000000..228b26c1 --- /dev/null +++ b/tests/remote-doc/la01-in.html @@ -0,0 +1,16 @@ + + + Content to be skipped + + + +

    This content should be skipped

    + + \ No newline at end of file diff --git a/tests/remote-doc/la01-out.jsonld b/tests/remote-doc/la01-out.jsonld new file mode 100644 index 00000000..a5d1e558 --- /dev/null +++ b/tests/remote-doc/la01-out.jsonld @@ -0,0 +1,3 @@ +[{ + "http://example.org/content": [{"@value": "alternate"}] +}] \ No newline at end of file diff --git a/tests/remote-doc/la02-alternate.jsonld b/tests/remote-doc/la02-alternate.jsonld new file mode 100644 index 00000000..672295e9 --- /dev/null +++ b/tests/remote-doc/la02-alternate.jsonld @@ -0,0 +1,6 @@ +{ + "@context": { + "@vocab": "http://example.org/" + }, + "content": "alternate" +} \ No newline at end of file diff --git a/tests/remote-doc/la02-in.jsonld b/tests/remote-doc/la02-in.jsonld new file mode 100644 index 00000000..05fcb19a --- /dev/null +++ b/tests/remote-doc/la02-in.jsonld @@ -0,0 +1,6 @@ +{ + "@context": { + "@vocab": "http://example.org/" + }, + "content": "not skipped" +} \ No newline at end of file diff --git a/tests/remote-doc/la02-out.jsonld b/tests/remote-doc/la02-out.jsonld new file mode 100644 index 00000000..e2c788c0 --- /dev/null +++ b/tests/remote-doc/la02-out.jsonld @@ -0,0 +1,3 @@ +[{ + "http://example.org/content": [{"@value": "not skipped"}] +}] \ No newline at end of file diff --git a/tests/remote-doc/la03-alternate.json b/tests/remote-doc/la03-alternate.json new file mode 100644 index 00000000..672295e9 --- /dev/null +++ b/tests/remote-doc/la03-alternate.json @@ -0,0 +1,6 @@ +{ + "@context": { + "@vocab": "http://example.org/" + }, + "content": "alternate" +} \ No newline at end of file diff --git a/tests/remote-doc/la03-in.json b/tests/remote-doc/la03-in.json new file mode 100644 index 00000000..05fcb19a --- /dev/null +++ b/tests/remote-doc/la03-in.json @@ -0,0 +1,6 @@ +{ + "@context": { + "@vocab": "http://example.org/" + }, + "content": "not skipped" +} \ No newline at end of file diff --git a/tests/remote-doc/la03-out.jsonld b/tests/remote-doc/la03-out.jsonld new file mode 100644 index 00000000..e2c788c0 --- /dev/null +++ b/tests/remote-doc/la03-out.jsonld @@ -0,0 +1,3 @@ +[{ + "http://example.org/content": [{"@value": "not skipped"}] +}] \ No newline at end of file diff --git a/tests/remote-doc/la04-alternate.jsonld b/tests/remote-doc/la04-alternate.jsonld new file mode 100644 index 00000000..672295e9 --- /dev/null +++ b/tests/remote-doc/la04-alternate.jsonld @@ -0,0 +1,6 @@ +{ + "@context": { + "@vocab": "http://example.org/" + }, + "content": "alternate" +} \ No newline at end of file diff --git a/tests/remote-doc/la04-in.json b/tests/remote-doc/la04-in.json new file mode 100644 index 00000000..05fcb19a --- /dev/null +++ b/tests/remote-doc/la04-in.json @@ -0,0 +1,6 @@ +{ + "@context": { + "@vocab": "http://example.org/" + }, + "content": "not skipped" +} \ No newline at end of file diff --git a/tests/remote-doc/la04-out.jsonld b/tests/remote-doc/la04-out.jsonld new file mode 100644 index 00000000..e2c788c0 --- /dev/null +++ b/tests/remote-doc/la04-out.jsonld @@ -0,0 +1,3 @@ +[{ + "http://example.org/content": [{"@value": "not skipped"}] +}] \ No newline at end of file diff --git a/tests/remote-doc/la05-alternate.jsonld b/tests/remote-doc/la05-alternate.jsonld new file mode 100644 index 00000000..8039161a --- /dev/null +++ b/tests/remote-doc/la05-alternate.jsonld @@ -0,0 +1,7 @@ +{ + "@context": { + "@vocab": "http://example.org/" + }, + "@id": "", + "content": "alternate" +} \ No newline at end of file diff --git a/tests/remote-doc/la05-in.html b/tests/remote-doc/la05-in.html new file mode 100644 index 00000000..4fb2995e --- /dev/null +++ b/tests/remote-doc/la05-in.html @@ -0,0 +1,17 @@ + + + Content to be skipped + + + +

    This content should be skipped

    + + \ No newline at end of file diff --git a/tests/remote-doc/la05-out.jsonld b/tests/remote-doc/la05-out.jsonld new file mode 100644 index 00000000..55700a0e --- /dev/null +++ b/tests/remote-doc/la05-out.jsonld @@ -0,0 +1,4 @@ +[{ + "@id": "https://w3c.github.io/json-ld-api/tests/remote-doc/la05-in.html", + "http://example.org/content": [{"@value": "alternate"}] +}] \ No newline at end of file