Skip to content

Use URL to extract/build page path

Instead of custom RegExps to extract hash and query params to the hash a builtin URL could be used.

const url = new URL(location.hash.slice(1, -1), 'http://internal/');
const params = url.searchParams.entries().next()

refs: