Fix GET form submission

This commit is contained in:
Robin North
2018-02-21 18:27:26 +00:00
parent b7fc3457de
commit a5b51f34df
3 changed files with 45 additions and 16 deletions

View File

@@ -0,0 +1,10 @@
module.exports = function(uri, key, value) {
var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i")
var separator = uri.indexOf("?") !== -1 ? "&" : "?"
if (uri.match(re)) {
return uri.replace(re, "$1" + key + "=" + value + "$2")
}
else {
return uri + separator + key + "=" + value
}
}