Fix instanceof bug between execution contexts

First encountered at jest-playwright repo:
https://github.com/mmarkelov/jest-playwright/issues/38

Solution based on:
https://stackoverflow.com/questions/4339288/typeof-for-regexp#comment4724685_4339350
This commit is contained in:
aesyondu 2020-02-17 20:50:02 +08:00 committed by GitHub
parent e65897844f
commit 3382c56c06
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -222,7 +222,7 @@ export function urlMatches(urlString: string, match: types.URLMatch | undefined)
return true;
if (helper.isString(match))
match = helper.globToRegex(match);
if (match instanceof RegExp)
if (match instanceof RegExp || match.constructor.name === "RegExp")
return match.test(urlString);
if (typeof match === 'string' && match === urlString)
return true;