ruby-rdf / json-ld

Ruby JSON-LD reader/writer for RDF.rb
The Unlicense
232 stars 27 forks source link

Canonicalize and dedup URLs in to_rb #61

Open jhawthorn opened 8 months ago

jhawthorn commented 8 months ago

JSON::LD::Context#parse will only look in the PRELOADED hash with a fully canonicalized URL including replacing https with http. This means that any preloads or aliases under non-canonicalized names won't work and can't be used and will just waste memory.

This commit fully canonicalizes both the base and alias URLs (including changing https to http) and removes any duplicates.

I considered adding error checking or canonicalization in add_preloaded and alias_preloaded as well, but I'll propose that separately as compatibility is tricky.

See also https://github.com/ruby-rdf/json-ld-preloaded/pull/7 where this is applied, and it ends up removing all aliases (they were unnecessary) and fixing a preload which previously was not working at all (attempting to use it would make the HTTP request).

CLAassistant commented 8 months ago

CLA assistant check
All committers have signed the CLA.