minurl.shared.d.ts 725 B

12345678910111213141516171819
  1. /**
  2. * Checks if a value has the shape of a WHATWG URL object.
  3. *
  4. * Using a symbol or instanceof would not be able to recognize URL objects
  5. * coming from other implementations (e.g. in Electron), so instead we are
  6. * checking some well known properties for a lack of a better test.
  7. *
  8. * We use `href` and `protocol` as they are the only properties that are
  9. * easy to retrieve and calculate due to the lazy nature of the getters.
  10. *
  11. * We check for auth attribute to distinguish legacy url instance with
  12. * WHATWG URL instance.
  13. *
  14. * @param {unknown} fileUrlOrPath
  15. * File path or URL.
  16. * @returns {fileUrlOrPath is URL}
  17. * Whether it’s a URL.
  18. */
  19. export function isUrl(fileUrlOrPath: unknown): fileUrlOrPath is URL