You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 1.0KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # isurl [![NPM Version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url]
  2. > Checks whether a value is a WHATWG [`URL`](https://developer.mozilla.org/en/docs/Web/API/URL).
  3. Works cross-realm/iframe and despite @@toStringTag.
  4. ## Installation
  5. [Node.js](http://nodejs.org/) `>= 4` is required. To install, type this at the command line:
  6. ```shell
  7. npm install isurl
  8. ```
  9. ## Usage
  10. ```js
  11. const isURL = require('isurl');
  12. isURL('http://domain/'); //-> false
  13. isURL(new URL('http://domain/')); //-> true
  14. ```
  15. Optionally, acceptance can be extended to incomplete `URL` implementations that lack `searchParams` (which are common in many modern web browsers):
  16. ```js
  17. const url = new URL('http://domain/?query');
  18. console.log(url.searchParams); //-> undefined
  19. isURL.lenient(url); //-> true
  20. ```
  21. [npm-image]: https://img.shields.io/npm/v/isurl.svg
  22. [npm-url]: https://npmjs.org/package/isurl
  23. [travis-image]: https://img.shields.io/travis/stevenvachon/isurl.svg
  24. [travis-url]: https://travis-ci.org/stevenvachon/isurl