Skip to content

Instantly share code, notes, and snippets.

@TorbjornHoltmon
Last active January 27, 2023 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TorbjornHoltmon/afa7e5e6c4367ef87432d293411d17b2 to your computer and use it in GitHub Desktop.
Save TorbjornHoltmon/afa7e5e6c4367ef87432d293411d17b2 to your computer and use it in GitHub Desktop.
Quickly parse url in console
const urlToTest = new URL("AddUrl");
let query = {};
for ([key, value] of urlToTest.searchParams) {
query[key] = value;
}
console.log({
host: urlToTest.host,
query: query,
path: urlToTest.pathname,
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment