Created
May 11, 2026 08:33
-
-
Save ashaffah/d8a75c016c4cf7368c5c0ba7d95b4ad2 to your computer and use it in GitHub Desktop.
url resolver
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (() => { | |
| const allowedParams = ["id", "page", "tab"]; | |
| const url = new URL(window.location); | |
| const params = url.searchParams; | |
| const currentKeys = Array.from(params.keys()); | |
| currentKeys.forEach((key) => { | |
| if (!allowedParams.includes(key)) { | |
| params.delete(key); | |
| } | |
| }); | |
| window.history.replaceState({}, "", url); | |
| })(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (() => { | |
| const url = new URL(window.location); | |
| for (const key of [...url.searchParams.keys()]) { | |
| if (!["id", "page", "tab"].includes(key)) url.searchParams.delete(key); | |
| } | |
| window.history.replaceState({}, "", url); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment