Use the URL global when available
This commit is contained in:
parent
844b43c9df
commit
42fd8d3574
1 changed files with 5 additions and 2 deletions
|
|
@ -2,7 +2,10 @@
|
||||||
/// <reference lib="es2017.sharedmemory"/>
|
/// <reference lib="es2017.sharedmemory"/>
|
||||||
/// <reference lib="esnext.asynciterable"/>
|
/// <reference lib="esnext.asynciterable"/>
|
||||||
/// <reference lib="dom"/>
|
/// <reference lib="dom"/>
|
||||||
import {URL} from 'url';
|
|
||||||
|
// TODO: Use the `URL` global when targeting Node.js 10
|
||||||
|
// tslint:disable-next-line
|
||||||
|
const URLGlobal = typeof URL === 'undefined' ? require('url').URL : URL;
|
||||||
|
|
||||||
type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
|
type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
|
||||||
type Primitive = null | undefined | string | number | boolean | Symbol;
|
type Primitive = null | undefined | string | number | boolean | Symbol;
|
||||||
|
|
@ -195,7 +198,7 @@ namespace is { // tslint:disable-line:no-namespace
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
new URL(value); // tslint:disable-line no-unused-expression
|
new URLGlobal(value); // tslint:disable-line no-unused-expression
|
||||||
return true;
|
return true;
|
||||||
} catch {
|
} catch {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue