From aa095cc048bbb5110c8163219db7eb2d41830c75 Mon Sep 17 00:00:00 2001 From: Vlad Frangu Date: Fri, 3 May 2019 10:18:36 +0300 Subject: [PATCH] src: Also revert the URL constructor removal --- source/index.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/index.ts b/source/index.ts index 285a198..945b2e4 100644 --- a/source/index.ts +++ b/source/index.ts @@ -1,6 +1,10 @@ /// /// +// TODO: Use the `URL` global when targeting Node.js 10 +// eslint-disable-next-line @typescript-eslint/no-require-imports +const URLGlobal = typeof URL === 'undefined' ? require('url').URL : URL; + export type Class = new (...args: any[]) => T; export const enum TypeName { @@ -192,7 +196,7 @@ is.urlString = (value: unknown): value is string => { } try { - new URL(value); // eslint-disable-line no-new + new URLGlobal(value); // eslint-disable-line no-new return true; } catch { return false;