test runner: Simplify getURLParameter()

This commit is contained in:
Richard Hansen 2020-11-25 13:18:11 -05:00 committed by John McLear
parent 958f7d8966
commit 5a8f7cf54e

View file

@ -154,12 +154,7 @@ $(() => {
}); });
}; };
// http://stackoverflow.com/questions/1403888/get-url-parameter-with-jquery const getURLParameter = (name) => (new URLSearchParams(location.search)).get(name);
const getURLParameter = function (name) {
return decodeURI(
(RegExp(`${name}=(.+?)(&|$)`).exec(location.search) || [null, null])[1]
);
};
// get the list of specs and filter it if requested // get the list of specs and filter it if requested
const specs = specs_list.slice(); const specs = specs_list.slice();
@ -179,7 +174,7 @@ $(() => {
helper.init(() => { helper.init(() => {
// configure and start the test framework // configure and start the test framework
const grep = getURLParameter('grep'); const grep = getURLParameter('grep');
if (grep !== 'null') { if (grep != null) {
mocha.grep(grep); mocha.grep(grep);
} }