diff options
Diffstat (limited to 'node_modules/isurl')
-rw-r--r-- | node_modules/isurl/LICENSE | 21 | ||||
-rw-r--r-- | node_modules/isurl/README.md | 39 | ||||
-rw-r--r-- | node_modules/isurl/index.js | 58 | ||||
-rw-r--r-- | node_modules/isurl/package.json | 32 |
4 files changed, 150 insertions, 0 deletions
diff --git a/node_modules/isurl/LICENSE b/node_modules/isurl/LICENSE new file mode 100644 index 0000000..274147a --- /dev/null +++ b/node_modules/isurl/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 Steven Vachon + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/isurl/README.md b/node_modules/isurl/README.md new file mode 100644 index 0000000..6903ac7 --- /dev/null +++ b/node_modules/isurl/README.md @@ -0,0 +1,39 @@ +# isurl [![NPM Version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] + +> Checks whether a value is a WHATWG [`URL`](https://developer.mozilla.org/en/docs/Web/API/URL). + + +Works cross-realm/iframe and despite @@toStringTag. + + +## Installation + +[Node.js](http://nodejs.org/) `>= 4` 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 `searchParams` (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.org/package/isurl +[travis-image]: https://img.shields.io/travis/stevenvachon/isurl.svg +[travis-url]: https://travis-ci.org/stevenvachon/isurl diff --git a/node_modules/isurl/index.js b/node_modules/isurl/index.js new file mode 100644 index 0000000..70ed1d7 --- /dev/null +++ b/node_modules/isurl/index.js @@ -0,0 +1,58 @@ +"use strict"; +const hasToStringTag = require("has-to-string-tag-x"); +const isObject = require("is-object"); + +const toString = Object.prototype.toString; +const urlClass = "[object URL]"; + +const hash = "hash"; +const host = "host"; +const hostname = "hostname"; +const href = "href"; +const password = "password"; +const pathname = "pathname"; +const port = "port"; +const protocol = "protocol"; +const search = "search"; +const username = "username"; + + + +const isURL = (url, supportIncomplete/*=false*/) => +{ + if (!isObject(url)) return false; + + // Native implementation in older browsers + if (!hasToStringTag && toString.call(url) === urlClass) return true; + + if (!(href in url)) return false; + if (!(protocol in url)) return false; + if (!(username in url)) return false; + if (!(password in url)) return false; + if (!(hostname in url)) return false; + if (!(port in url)) return false; + if (!(host in url)) return false; + if (!(pathname in url)) return false; + if (!(search in url)) return false; + if (!(hash in url)) return false; + + if (supportIncomplete !== true) + { + if (!isObject(url.searchParams)) return false; + + // TODO :: write a separate isURLSearchParams ? + } + + return true; +} + + + +isURL.lenient = url => +{ + return isURL(url, true); +}; + + + +module.exports = isURL; diff --git a/node_modules/isurl/package.json b/node_modules/isurl/package.json new file mode 100644 index 0000000..0852723 --- /dev/null +++ b/node_modules/isurl/package.json @@ -0,0 +1,32 @@ +{ + "name": "isurl", + "description": "Checks whether a value is a WHATWG URL.", + "version": "1.0.0", + "license": "MIT", + "author": "Steven Vachon <contact@svachon.com> (https://www.svachon.com/)", + "repository": "stevenvachon/isurl", + "dependencies": { + "has-to-string-tag-x": "^1.2.0", + "is-object": "^1.0.1" + }, + "devDependencies": { + "chai": "^4.0.2", + "mocha": "^3.4.2", + "semver": "^5.3.0", + "universal-url": "^1.0.0" + }, + "engines": { + "node": ">= 4" + }, + "scripts": { + "test": "mocha test --check-leaks --bail" + }, + "files": [ + "index.js" + ], + "keywords": [ + "uri", + "url", + "whatwg" + ] +} |