json-ld
json-ld copied to clipboard
Canonicalize and dedup URLs in to_rb
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).