rubensworks / jsonld-context-parser.js

Parses JSON-LD contexts
MIT License
26 stars 9 forks source link

support text/plain when json-ld mediatype is not provided #44

Open EmidioStani opened 2 years ago

EmidioStani commented 2 years ago

Hello,

I was trying to use your library by parsing a remote context on GitHub as raw file. The problem is that by using raw content, GitHub provides text/plain.

So would it possible to parse it as least text/plain when the json-ld mediatype is not provided or let the user decide which mediatype should be looking for.

Thanks,

Emidio

rubensworks commented 2 years ago

In the near term, you could pass a custom fetch function into the constructor, which injects the required content-type in the response header.

But I'm also open to a PR that adds a (non-default) option to pass a custom response content-type override.

j-steinbach commented 1 year ago

This is also relevant when a document exposes itself as the wrong application type.

For example https://w3c.github.io/vc-di-bbs/contexts/v1/ has content-type | application/json; charset=utf-8. This in turn breaks JSON-LD documents stored on a Solid pod, or at least makes them not accessible via tools like Solid Pod Browsers such as Penny ("No permission to access this resource") or via the Firefox RDF Browser extension (Error: Failed to load remote context https://w3id.org/security/bbs/v1: Unsupported JSON-LD media type application/json).