It's a classic filter bug: a user clicks multiple tags, the address bar shows ?tag=css&tag=js&tag=css, yet only one tag stays selected on the page. The mistake usually hides in how you parse the query string—the part of the URL after ? that holds query parameters.
Browsers, Node.js, Deno, and Bun all include the built-in URLSearchParams interface for this. Its get() method returns only the first match (or null if the key is missing) and silently ignores the rest. To get the full array in original URL order with duplicates intact, call getAll(), which returns an empty array [] when a key isn't present.
const params = new URLSearchParams("tag=css&tag=js&tag=css");
// Returns only the first value
console.log(params.get("tag")); // "css"
// Returns all values in order, including duplicates
console.log(params.getAll("tag")); // ["css", "js", "css"]
// Trap: Object.fromEntries keeps only the last value
console.log(Object.fromEntries(params)); // { tag: "css" }
If you pass params into Object.fromEntries(), the key gets overwritten by the last occurrence (tag=css&tag=js&tag=html yields "html"). So for multi-value filters, reach for getAll(), strip duplicates with [...new Set(params.getAll("tag"))], and cast numbers or booleans manually since the method always returns strings.

