From 3382c56c06efb05e8595aaf88f05723bbfb8c026 Mon Sep 17 00:00:00 2001 From: aesyondu <57334943+aesyondu@users.noreply.github.com> Date: Mon, 17 Feb 2020 20:50:02 +0800 Subject: [PATCH] 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 --- src/platform.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform.ts b/src/platform.ts index 7015b89519..35fc5b63cf 100644 --- a/src/platform.ts +++ b/src/platform.ts @@ -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;