Addon icon indicating copy to clipboard operation
Addon copied to clipboard

CleanURLs breaks the History API

Open adolfintel opened this issue 2 years ago • 3 comments

I noticed this bug while working on my website.

If you do

history.pushState({something:"value"}, "", newURL)

and then press the back button, normally the window.onpopstate function gets called with an event, and you can get the state (first parameter in the code above) with event.state and you can get the value of something from there.

When CleanURLs is enabled, however, that original value is lost and I just get a generic state without the information needed to actually go back to the previous state in my code.

I don't know if this is intentional or not but I imagine it breaks virtually every site using that API.

I forgot to mention: I'm using Librewolf, a Firefox-based browser.

adolfintel avatar Aug 02 '23 08:08 adolfintel

This is a kind of duplicate of #196. Now that I look into it, it seems my PR there was written too hastily, instead of: code: 'history.replaceState({state: null},"",'+JSON.stringify(urlAfter)+');' it should have been: code: 'history.replaceState(null,"",'+JSON.stringify(urlAfter)+');'

However, maybe we should reconsider the second solution suggested in that thread:

do not clean history if the hostname stays the same -- we could probably accept that inside one hostname it's acceptable that websites use the history information.

evertheylen avatar Oct 18 '23 09:10 evertheylen