1
0
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:
Eric Cornelissen 2020-07-31 19:52:07 +03:00 committed by GitHub
parent 8e59a517b5
commit 185218ed5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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, ' '));