kianschmalenbach / rdf-browser

A Firefox Add-on that requests RDF files and renders RDF files as Turtle documents with clickable links
MIT License
16 stars 6 forks source link

Reloading HTTP links #21

Closed kernc closed 3 years ago

kernc commented 3 years ago

Issue: Each time one clicks on a reference to an entity in a current document, the document is reloaded. This is a result of the references normally pointing to http: protocol whereas the documents are sometimes served over https: protocol.

Reproducible example:

  1. Go to http://www.w3.org/2000/01/rdf-schema#label (notice being redirected to https).
  2. Click on any rdfs: link.
  3. Notice the page being reloaded.

Instead, one ought to just jump to the appropriate section by a change of hash fragment, without re-retrieving the document.

I recommend to clean the entity's URL here: https://github.com/kianschmalenbach/rdf-browser/blob/5e3749a5a23dcc7bc739df2817b34d5556360259/src/bdo/resource.js#L78-L79 Something like:

function relativize_url(url) {
    let url = new URL(url);
    if (url.host == window.location.host && 
            url.pathname == window.location.pathname)
        return url.hash;
    return url.href;
}

...

link.setAttribute("href", encodeURI(relativize_url(this.value))); 

Excellent addon! Cheers,

kianschmalenbach commented 3 years ago

Hi, Thanks for your feedback! This issue should be fixed with current version 1.2.0.

Cheers, Kian