我需要添加或者,如果它已经存在,修改 URL 查询字符串的一个参数。
例如,如果我想设置param为 value newvalue,
http://example.org/file.php应该导致http://example.org/file.php?param=newvalue
http://example.org/file.php?abc=def应该导致http://example.org/file.php?abc=def¶m=newvalue
http://example.org/file.php?param=oldValue应该导致http://example.org/file.php?param=newvalue
我知道URI.js库,但它的最小可能大小 21kb(非压缩)对我来说太大了。
我正在寻找一个小型库来修改 url-query-strings,或者为我做这件事的一小段代码。