16 lines
761 B
JavaScript
16 lines
761 B
JavaScript
/**
|
|
* filter-url.js — the address after this page drops its OWN filter keys.
|
|
*
|
|
* The tables page reads a deep-link filter from the query (?iso= / ?country= / ?label= / ?province=).
|
|
* "Show all" must remove exactly those keys: the page's ?tab=, any key a host or a partner put on the
|
|
* address, and the #hash are someone else's and stay as they were. Pure (no DOM), so a node check can
|
|
* prove it without a browser.
|
|
*/
|
|
export const FILTER_KEYS = ['iso', 'country', 'label', 'province']
|
|
|
|
/** `href` without `keys`, as pathname + search + hash (what history.replaceState takes). */
|
|
export function withoutKeys(href, keys = FILTER_KEYS) {
|
|
const u = new URL(href)
|
|
for (const k of keys) u.searchParams.delete(k)
|
|
return u.pathname + u.search + u.hash
|
|
}
|