From 403b06b438ebb16ec90a7c503c17732eb36c31d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Kr=C3=B6g?= Date: Fri, 5 Aug 2022 01:09:03 +0200 Subject: [PATCH] Use RegExp#test intead of String#match --- config/jsdoc/plugins/api.cjs | 6 +++--- examples/modify-test.js | 5 +---- src/ol/has.js | 2 +- test/rendering/test.js | 2 +- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/config/jsdoc/plugins/api.cjs b/config/jsdoc/plugins/api.cjs index c50a57c990..828bc1f9b8 100644 --- a/config/jsdoc/plugins/api.cjs +++ b/config/jsdoc/plugins/api.cjs @@ -81,10 +81,10 @@ function includeAugments(doclet) { function extractTypes(item) { item.type.names.forEach(function (type) { - const match = type.match(/^(.*<)?([^>]*)>?$/); + const match = type.match(/^(?:.*<)?([^>]*)>?$/); if (match) { - modules[match[2]] = true; - types[match[2]] = true; + modules[match[1]] = true; + types[match[1]] = true; } }); } diff --git a/examples/modify-test.js b/examples/modify-test.js index 13f6b17384..d2010a4f9c 100644 --- a/examples/modify-test.js +++ b/examples/modify-test.js @@ -321,10 +321,7 @@ const modify = new Modify({ .getFeatures() .getArray() .every(function (feature) { - return feature - .getGeometry() - .getType() - .match(/Polygon/); + return /Polygon/.test(feature.getGeometry().getType()); }); }, }); diff --git a/src/ol/has.js b/src/ol/has.js index 9284561333..26ed0753cb 100644 --- a/src/ol/has.js +++ b/src/ol/has.js @@ -26,7 +26,7 @@ export const SAFARI = ua.includes('safari') && !ua.includes('chrom'); export const SAFARI_BUG_237906 = SAFARI && (ua.includes('version/15.4') || - !!ua.match(/cpu (os|iphone os) 15_4 like mac os x/)); + /cpu (os|iphone os) 15_4 like mac os x/.test(ua)); /** * User agent string says we are dealing with a WebKit engine. diff --git a/test/rendering/test.js b/test/rendering/test.js index 731533afac..803960dc92 100755 --- a/test/rendering/test.js +++ b/test/rendering/test.js @@ -48,7 +48,7 @@ function indexHandler(req, res) { function notFound(req, res) { return () => { // first, try the default directory - if (req.url.match(/^\/cases\/[^\/]+\/(index.html)?$/)) { + if (/^\/cases\/[^\/]+\/(index.html)?$/.test(req.url)) { // request for a case index file, and file not found, use default req.url = '/index.html'; return defaultHandler(req, res, () => indexHandler(req, res));