Skip to content

CleanURLs breaks the History API #311

Description

@adolfintel

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.

Activity

  1. evertheylen commented on Oct 18, 2023

    @evertheylen
    Contributor

    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.

  2. KevinRoebert commented on Mar 28, 2025

    @KevinRoebert
    Member

    Hi. Is this still an issue?

  3. adolfintel commented on Mar 29, 2025

    @adolfintel
    Author

    Yep

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions