https://github.com/stevenvachon/isurl
Determines whether a value is a WHATWG URL.
https://github.com/stevenvachon/isurl
nodejs url whatwg
Last synced: 6 months ago
JSON representation
Determines whether a value is a WHATWG URL.
- Host: GitHub
- URL: https://github.com/stevenvachon/isurl
- Owner: stevenvachon
- License: mit
- Created: 2017-02-21T19:50:29.000Z (over 8 years ago)
- Default Branch: main
- Last Pushed: 2021-02-27T21:17:59.000Z (over 4 years ago)
- Last Synced: 2025-04-28T16:12:37.149Z (6 months ago)
- Topics: nodejs, url, whatwg
- Language: JavaScript
- Homepage:
- Size: 10.7 KB
- Stars: 12
- Watchers: 1
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# isurl [![NPM Version][npm-image]][npm-url] ![File Size][filesize-image] [![Build Status][travis-image]][travis-url] [![Dependency Monitor][greenkeeper-image]][greenkeeper-url]
> Determines whether a value is a WHATWG [`URL`](https://mdn.io/URL).
Works cross-realm/iframe and despite `Symbol.toStringTag`.
## Installation
[Node.js](https://nodejs.org) `>= 8` is required. To install, type this at the command line:
```shell
npm install isurl
```## Usage
```js
const isURL = require('isurl');isURL('http://domain/'); //-> false
isURL(new URL('http://domain/')); //-> true
```Optionally, acceptance can be extended to incomplete `URL` implementations that lack `origin`, `searchParams` and `toJSON` properties (which are common in many modern web browsers):
```js
const url = new URL('http://domain/?query');console.log(url.searchParams); //-> undefined
isURL.lenient(url); //-> true
```[npm-image]: https://img.shields.io/npm/v/isurl.svg
[npm-url]: https://npmjs.com/package/isurl
[filesize-image]: https://img.shields.io/badge/bundle-3.1kB%20gzipped-blue.svg
[travis-image]: https://img.shields.io/travis/stevenvachon/isurl.svg
[travis-url]: https://travis-ci.org/stevenvachon/isurl
[greenkeeper-image]: https://badges.greenkeeper.io/stevenvachon/isurl.svg
[greenkeeper-url]: https://greenkeeper.io/