Urara-Blog/node_modules/.pnpm-store/v3/files/3f/b70d0ec3519acee46c2963805c35f746f6fce326eec790f9ac89ab103fd406dffd749eef6121954ab095fa4073540aa3b5c2f342e82d4e2446f65ce6e4439a
2022-08-14 01:14:53 +08:00

33 lines
858 B
Text

/**
* @typedef URL
* @property {string} hash
* @property {string} host
* @property {string} hostname
* @property {string} href
* @property {string} origin
* @property {string} password
* @property {string} pathname
* @property {string} port
* @property {string} protocol
* @property {string} search
* @property {any} searchParams
* @property {string} username
* @property {() => string} toString
* @property {() => string} toJSON
*/
/**
* @param {unknown} fileURLOrPath
* @returns {fileURLOrPath is URL}
*/
// From: <https://github.com/nodejs/node/blob/fcf8ba4/lib/internal/url.js#L1501>
export function isUrl(fileURLOrPath) {
return (
fileURLOrPath !== null &&
typeof fileURLOrPath === 'object' &&
// @ts-expect-error: indexable.
fileURLOrPath.href &&
// @ts-expect-error: indexable.
fileURLOrPath.origin
)
}