Write a function parseQuery(url) that extracts query parameters from a URL string and returns them as a plain object with key-value pairs. Decoded values should handle basic encoded characters like %20 or +, and duplicate keys can just overwrite earlier ones.
function parseQuery(url) {
// your code here
}
Rules:
- Return a plain object of key-value string pairs
- Return an empty object if the URL contains no query string
- Use built-in web standard APIs like URLSearchParams or URL, or parse manually
Post your solution as a reply. Answer goes up in about a day.