Write a function parseQuery(queryString) that parses a URL query string (with or without a leading ?) into an object of key-value pairs. Decoded values should be properly unescaped (e.g., %20 or + becoming spaces).
function parseQuery(queryString) {
// Your code here
}
Rules:
- Must handle query strings starting with or without a leading ‘?’
- Must decode percent-encoded characters and ‘+’ as spaces
- Return an empty object if the input is empty or just ‘?’
Post your solution as a reply. Answer goes up in about a day.