Parse query parameters
URLs can have optional query parameters. They are the key-value pairs that follow the path.
Write a function that takes a URL (represented as a string) and parses out the query parameters into a hashmap.
- The query string is the string containing the query parameters. It appears after the ? and before a #. Ex:
- The keys and values are URL Encoded. You can use
java.net.URLDecoder/decodeto decode them.
- The key-value pairs are separated by
- Each key-value pair contains the key, followed by
=, followed by the value. Ex:
Query parameters can contain duplicate keys. Handle them gracefully.