Fix form submission (#129)
* Fix check for radio and checkbox inputs * Fix GET form submission * Add example forms for testing * Refactor query string building
This commit was merged in pull request #129.
This commit is contained in:
10
lib/util/update-query-string.js
Normal file
10
lib/util/update-query-string.js
Normal 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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user