visionmedia / page.js

Micro client-side router inspired by the Express router
http://visionmedia.github.com/page.js
7.67k stars 687 forks source link

Fix duplicate query string params when hashbang is enabled #584

Open jasonwoan opened 3 years ago

jasonwoan commented 3 years ago

Problem

When hashbang is enabled, page.start() will re-add location.search params to the hash. This results in duplicate query params when the page is refreshed.

See #525 and #412

Proposed Fix

Add location.search params only when a query string has not been added to the hash.

Notes

It was a challenge to test this. I couldn't figure out how to supply a query string to the iframe window. I ended up configuring jsdom with a query string and testing against window.location. Please advise if there is a better approach.

coveralls commented 3 years ago

Coverage Status

Coverage increased (+0.4%) to 93.443% when pulling 5ce222203a2f309b6cdc219f78488940e7061af3 on jasonwoan:fix/duplicate-qs into 4f9991658f9b9e3de9b6059bade93693af24d6bd on visionmedia:master.