mirror of
https://github.com/simple-icons/simple-icons.git
synced 2025-01-05 01:20:39 +02:00
Fully escape parameter before use in Regexp (#3391)
* Fully escape parameter before use in Regexp * Update ref URL for escaping
This commit is contained in:
parent
8e59a517b5
commit
185218ed5f
@ -54,12 +54,12 @@
|
||||
};
|
||||
}
|
||||
|
||||
// Get any parameter from the URL's search section (location.search).
|
||||
// see
|
||||
// Get a parameter from the URL's search section (location.search). Based on:
|
||||
// - https://davidwalsh.name/query-string-javascript
|
||||
// - https://github.com/WebReflection/url-search-params
|
||||
// - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Escaping
|
||||
function getUrlParameter(parameter) {
|
||||
var name = parameter.replace(/[\[]/g, '\\[').replace(/[\]]/g, '\\]');
|
||||
var name = parameter.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
|
||||
var results = regex.exec(location.search);
|
||||
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
|
||||
|
Loading…
Reference in New Issue
Block a user