Skip to content

Comments

feat: add RFC 3986 relative IRI resolution#9

Closed
soyuka wants to merge 4 commits intodunglas:mainfrom
soyuka:feat/iri-resolution
Closed

feat: add RFC 3986 relative IRI resolution#9
soyuka wants to merge 4 commits intodunglas:mainfrom
soyuka:feat/iri-resolution

Conversation

@soyuka
Copy link

@soyuka soyuka commented Feb 23, 2026

Summary

  • Adds IriHelper::resolve() implementing RFC 3986 §5 relative reference resolution
  • Needed because CSS JSON-LD responses may contain relative @id values
  • Handles all RFC 3986 edge cases: dot segments, authority-relative, query/fragment

Stack

4/8 — builds on #8 (feat/jsonld-parsing)

Test plan

  • Full RFC 3986 §5.4 normal examples via data provider (22 cases)
  • Solid Pod-specific relative ID resolution tests
  • Absolute reference passthrough test

🤖 Generated with Claude Code

soyuka and others added 4 commits February 23, 2026 17:09
Implements the four missing LDP HTTP methods:
- put(): idempotent resource creation/update at a known URI, with optional
  LDP BasicContainer Link header for container creation
- head(): inspect resource metadata without fetching the body
- delete(): remove resources or containers
- patch(): partial RDF updates via SPARQL Update (default) or N3 Patch

Also applies CS Fixer auto-fixes (explicit nullable types, \sprintf).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds ResourceMetadata, a typed value object parsed from HEAD response
headers providing: contentType, contentLength, lastModified, ldpType
(container vs resource from Link header), wacAllow (parsed permissions),
and aclUrl (from Link rel="acl").

Adds getResourceMetadata() to SolidClient as a convenience wrapper.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
CSS returns expanded JSON-LD by default for Accept: application/ld+json.
JsonLdParser uses json_decode directly (not the ml/json-ld processor)
since CSS responses are already in expanded form. Provides parse() for
normalizing single objects and arrays, and findById() for node lookup.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
IriHelper::resolve() implements RFC 3986 §5 for resolving relative
references against a base URI. Needed because CSS JSON-LD responses
may contain relative @id values that must be resolved against the
request URL.

Tested against the full RFC 3986 §5.4 normal examples.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@soyuka
Copy link
Author

soyuka commented Feb 23, 2026

CSS (Community Solid Server) returns JSON-LD with relative @id values when you GET a container with Accept: application/ld+json. For example, GETting http://pod.example/data/:

  {
    "@id": "./",
    "@type": ["http://www.w3.org/ns/ldp#BasicContainer"],
    "http://www.w3.org/ns/ldp#contains": [
      { "@id": "file.txt" },
      { "@id": "sub/" }
    ]
  }

The @id values "file.txt" and "sub/" are relative references — they're not usable as-is. To construct the actual resource URLs (http://pod.example/data/file.txt,
http://pod.example/data/sub/), you need to resolve them against the base URL of the request.

getContainerContents() (f259316) uses IriHelper::resolve() on every @id from the JSON-LD response to turn relative references into absolute URLs that can be used for subsequent requests (HEAD, GET,
DELETE, etc).

Without it, container listing would only work when CSS happens to return absolute URLs — which it doesn't by default.

@soyuka soyuka closed this Feb 23, 2026
@soyuka soyuka deleted the feat/iri-resolution branch February 23, 2026 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant