P粉1634659052023-08-21 11:15:52
Modern browsers provide the URLSearchParams
interface to handle search parameters. This interface has a delete
method to delete parameters based on their names.
1 2 3 4 5 6 7 8 9 10 11 12 |
|
P粉5069638422023-08-21 09:30:25
1 |
|
Looks dangerous because the parameter 'bar' will match:
1 |
|
In addition, if parameter
contains any characters that have special meaning in regular expressions, such as '.', this regular expression will fail. And it's not a global regex, so only one instance of the parameter will be removed.
I wouldn't use a simple regex to do this, I would parse the parameters and discard the ones I don't need.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
|