Beta 7 with some repo names changed.
This commit is contained in:
1 parent
0f7b40cca7
commit
963c19493a
3408 files changed
+462217
-15516
No files matched your search
+58
@@ -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;
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"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"
|
||||
]
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/isurl/-/isurl-1.0.0.tgz"
|
||||
,"_integrity": "sha512-1P/yWsxPlDtn7QeRD+ULKQPaIaN6yF368GZ2vDfv0AL0NwpStafjWCDDdn0k8wgFMWpVAqG7oJhxHnlud42i9w=="
|
||||
,"_from": "isurl@^1.0.0-alpha5"
|
||||
}
|
||||
Reference in new issue
Block a user