diff --git a/src/misc/utils.ts b/src/misc/utils.ts index d91b64209c..0ff14d3dbd 100644 --- a/src/misc/utils.ts +++ b/src/misc/utils.ts @@ -1,3 +1,6 @@ +// tslint:disable-next-line +const nodeURL = typeof window === 'undefined' ? require('url').URL : null; + export class Utils { static inited = false; static isNode = false; @@ -159,7 +162,7 @@ export class Utils { if (uriString.startsWith('http://') || uriString.startsWith('https://')) { try { - return new URL(uriString); + return nodeURL != null ? new nodeURL(uriString) : new URL(uriString); } catch (e) { } }