You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
URLs with redundant slashes cause Unpoly to trigger a DOMException #612
While testing an application which was using Unpoly, I noticed that the Cookie Banner was somehow not working at all.
The culprit however was the JavaScript exception within Unpoly's source code:
Due to a copy&paste mistake I was accessing the page at http://foobar.lvh.me:3000//en/sign-in' (two forward slashes) instead of http://foobar.lvh.me:3000/en/sign-in'. That's a niche case, but as the application renders fine in this case I'd except Unpoly not to crash too.
Steps to reproduce the behavior:
Go to https://unpoly.com//install
See the following error in the console:
Uncaught DOMException: Failed to execute 'replaceState' on 'History': A history state object with URL 'https://install/' cannot be created in a document with origin 'https://unpoly.com' and URL 'https://unpoly.com//install'.
Reproduced this at https://unpoly.com//install too — the doubled slash makes the browser treat the target as a protocol-relative/cross-origin URL, so history.replaceState throws DOMException. A cheap fix would be to normalize consecutive slashes (or at least strip a leading // after the origin) before any replaceState/pushState call in the navigation layer. Even without full normalization, guarding the history call so a malformed URL degrades to a plain navigation instead of crashing would prevent the hard failure. Happy to trace where the URL gets handed to history if a pointer helps.
Activity
adam12 commentedon May 8, 2024
Thanks for the report. I see the same on Safari + MacOS.
hiSandog commentedon Jun 29, 2026
Reproduced this at
https://unpoly.com//installtoo — the doubled slash makes the browser treat the target as a protocol-relative/cross-origin URL, sohistory.replaceStatethrowsDOMException. A cheap fix would be to normalize consecutive slashes (or at least strip a leading//after the origin) before anyreplaceState/pushStatecall in the navigation layer. Even without full normalization, guarding the history call so a malformed URL degrades to a plain navigation instead of crashing would prevent the hard failure. Happy to trace where the URL gets handed to history if a pointer helps.