astro-ghostcms/.pnpm-store/v3/files/a6/9728bec4a7eaeeef407a27dc5a6...

20 lines
725 B
Plaintext
Raw Normal View History

2024-02-14 14:10:47 +00:00
/**
* Checks if a value has the shape of a WHATWG URL object.
*
* Using a symbol or instanceof would not be able to recognize URL objects
* coming from other implementations (e.g. in Electron), so instead we are
* checking some well known properties for a lack of a better test.
*
* We use `href` and `protocol` as they are the only properties that are
* easy to retrieve and calculate due to the lazy nature of the getters.
*
* We check for auth attribute to distinguish legacy url instance with
* WHATWG URL instance.
*
* @param {unknown} fileUrlOrPath
* File path or URL.
* @returns {fileUrlOrPath is URL}
* Whether its a URL.
*/
export function isUrl(fileUrlOrPath: unknown): fileUrlOrPath is URL