This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Add / Update a key-value pair in the URL query parameters ### | |
updateUrlParameter = (uri, key, value)-> | |
# Remove the hash part before operating on the uri | |
i = uri.indexOf('#') | |
hash = if i == -1 then '' else uri.substr(i) | |
uri = if i == -1 then uri else uri.substr(0, i) | |
re = new RegExp("([?&])" + key + "=.*?(&|$)", "i") | |
separator = if uri.indexOf('?') != -1 then "&" else "?" | |
if uri.match(re) |