package/package.json000644 0000002647 3560116604 011557 0ustar00000000 000000 { "name": "isurl", "description": "Determines whether a value is a WHATWG URL.", "version": "4.0.1", "license": "MIT", "author": "Steven Vachon (https://svachon.com)", "repository": "github:stevenvachon/isurl", "main": "lib", "browser": "lib-es5", "dependencies": { "has-to-string-tag-x": "^1.4.1", "is-object": "^1.0.1", "is-urlsearchparams": "^1.0.1" }, "devDependencies": { "@babel/cli": "^7.4.3", "@babel/core": "^7.4.3", "@babel/preset-env": "^7.4.3", "babelify": "^10.0.0", "browserify": "^16.2.3", "chai": "^4.2.0", "coveralls": "^3.0.3", "decache": "^4.5.1", "gzip-size-cli": "^3.0.0", "incomplete-symbol": "^1.0.0", "incomplete-url": "^4.0.0", "mocha": "^6.1.4", "nyc": "^14.0.0", "terser": "^3.17.0", "whatwg-url": "^7.0.0" }, "engines": { "node": ">= 8" }, "scripts": { "ci": "npm run test && nyc report --reporter=text-lcov | coveralls", "posttest": "nyc report --reporter=html && browserify lib --global-transform [ babelify --presets [ @babel/env ] ] --standalone=isURL | terser --compress --mangle | gzip-size", "prepublishOnly": "npm test && babel lib/ --out-dir=lib-es5/ --presets=@babel/env --source-maps", "test": "nyc --reporter=text-summary mocha test.js --check-leaks --bail" }, "files": [ "lib", "lib-es5" ], "keywords": [ "uri", "url", "whatwg" ] } package/LICENSE000644 0000002056 3560116604 010270 0ustar00000000 000000 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. package/README.md000644 0000002510 3560116604 010535 0ustar00000000 000000 # 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://developer.mozilla.org/en/docs/Web/API/URL). Works cross-realm/iframe and despite `Symbol.toStringTag`. ## Installation [Node.js](http://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/size-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/ package/lib-es5/index.js000644 0000002426 3560116604 012171 0ustar00000000 000000 "use strict"; var hasToStringTag = require("has-to-string-tag-x"); var isObject = require("is-object"); var isURLSearchParams = require("is-urlsearchparams"); var _require = require("./props"), lenientProperties = _require.lenientProperties, strictProperties = _require.strictProperties; var searchParams = "searchParams"; var toStringTag = Object.prototype.toString; var urlClass = "[object URL]"; var isURL = function isURL(url) { var supportIncomplete = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; if (!isObject(url)) { return false; } else if (hasToStringTag && toStringTag.call(url) !== urlClass) { // Shimmed implementation with incorrect constructor name return false; } else if (!strictProperties.every(function (prop) { return prop in url; })) { return false; } else if (supportIncomplete && searchParams in url) { return isURLSearchParams.lenient(url.searchParams); } else if (supportIncomplete) { return true; } else if (lenientProperties.every(function (prop) { return prop in url; })) { return isURLSearchParams(url.searchParams); } else { return false; } }; isURL.lenient = function (url) { return isURL(url, true); }; module.exports = isURL; //# sourceMappingURL=index.js.mappackage/lib-es5/index.js.map000644 0000005151 3560116604 012743 0ustar00000000 000000 {"version":3,"sources":["../lib/index.js"],"names":["hasToStringTag","require","isObject","isURLSearchParams","lenientProperties","strictProperties","searchParams","toStringTag","Object","prototype","toString","urlClass","isURL","url","supportIncomplete","call","every","prop","lenient","module","exports"],"mappings":"AAAA;;AACA,IAAMA,cAAc,GAAGC,OAAO,CAAC,qBAAD,CAA9B;;AACA,IAAMC,QAAQ,GAAGD,OAAO,CAAC,WAAD,CAAxB;;AACA,IAAME,iBAAiB,GAAGF,OAAO,CAAC,oBAAD,CAAjC;;eAC8CA,OAAO,CAAC,SAAD,C;IAA9CG,iB,YAAAA,iB;IAAmBC,gB,YAAAA,gB;;AAE1B,IAAMC,YAAY,GAAG,cAArB;AACA,IAAMC,WAAW,GAAGC,MAAM,CAACC,SAAP,CAAiBC,QAArC;AACA,IAAMC,QAAQ,GAAG,cAAjB;;AAIA,IAAMC,KAAK,GAAG,SAARA,KAAQ,CAACC,GAAD,EACd;AAAA,MADoBC,iBACpB,uEADsC,KACtC;;AACC,MAAI,CAACZ,QAAQ,CAACW,GAAD,CAAb,EACA;AACC,WAAO,KAAP;AACA,GAHD,MAIK,IAAIb,cAAc,IAAIO,WAAW,CAACQ,IAAZ,CAAiBF,GAAjB,MAAwBF,QAA9C,EACL;AACC;AACA,WAAO,KAAP;AACA,GAJI,MAKA,IAAI,CAACN,gBAAgB,CAACW,KAAjB,CAAuB,UAAAC,IAAI;AAAA,WAAIA,IAAI,IAAIJ,GAAZ;AAAA,GAA3B,CAAL,EACL;AACC,WAAO,KAAP;AACA,GAHI,MAIA,IAAIC,iBAAiB,IAAIR,YAAY,IAAIO,GAAzC,EACL;AACC,WAAOV,iBAAiB,CAACe,OAAlB,CAA0BL,GAAG,CAACP,YAA9B,CAAP;AACA,GAHI,MAIA,IAAIQ,iBAAJ,EACL;AACC,WAAO,IAAP;AACA,GAHI,MAIA,IAAIV,iBAAiB,CAACY,KAAlB,CAAwB,UAAAC,IAAI;AAAA,WAAIA,IAAI,IAAIJ,GAAZ;AAAA,GAA5B,CAAJ,EACL;AACC,WAAOV,iBAAiB,CAACU,GAAG,CAACP,YAAL,CAAxB;AACA,GAHI,MAKL;AACC,WAAO,KAAP;AACA;AACD,CA/BD;;AAmCAM,KAAK,CAACM,OAAN,GAAgB,UAAAL,GAAG;AAAA,SAAID,KAAK,CAACC,GAAD,EAAM,IAAN,CAAT;AAAA,CAAnB;;AAIAM,MAAM,CAACC,OAAP,GAAiBR,KAAjB","sourcesContent":["\"use strict\";\nconst hasToStringTag = require(\"has-to-string-tag-x\");\nconst isObject = require(\"is-object\");\nconst isURLSearchParams = require(\"is-urlsearchparams\");\nconst {lenientProperties, strictProperties} = require(\"./props\");\n\nconst searchParams = \"searchParams\";\nconst toStringTag = Object.prototype.toString;\nconst urlClass = \"[object URL]\";\n\n\n\nconst isURL = (url, supportIncomplete=false) =>\n{\n\tif (!isObject(url))\n\t{\n\t\treturn false;\n\t}\n\telse if (hasToStringTag && toStringTag.call(url)!==urlClass)\n\t{\n\t\t// Shimmed implementation with incorrect constructor name\n\t\treturn false;\n\t}\n\telse if (!strictProperties.every(prop => prop in url))\n\t{\n\t\treturn false;\n\t}\n\telse if (supportIncomplete && searchParams in url)\n\t{\n\t\treturn isURLSearchParams.lenient(url.searchParams);\n\t}\n\telse if (supportIncomplete)\n\t{\n\t\treturn true;\n\t}\n\telse if (lenientProperties.every(prop => prop in url))\n\t{\n\t\treturn isURLSearchParams(url.searchParams);\n\t}\n\telse\n\t{\n\t\treturn false;\n\t}\n};\n\n\n\nisURL.lenient = url => isURL(url, true);\n\n\n\nmodule.exports = isURL;\n"],"file":"index.js"}package/lib-es5/props.js000644 0000000607 3560116604 012224 0ustar00000000 000000 "use strict"; var lenientProperties = ["origin", "searchParams", "toJSON"]; var strictProperties = ["hash", "host", "hostname", "href", "password", "pathname", "port", "protocol", "search", // "toString" excluded because Object::toString exists "username"]; module.exports = { lenientProperties: lenientProperties, strictProperties: strictProperties }; //# sourceMappingURL=props.js.mappackage/lib-es5/props.js.map000644 0000001555 3560116604 013003 0ustar00000000 000000 {"version":3,"sources":["../lib/props.js"],"names":["lenientProperties","strictProperties","module","exports"],"mappings":"AAAA;;AAEA,IAAMA,iBAAiB,GACvB,CACC,QADD,EAEC,cAFD,EAGC,QAHD,CADA;AAOA,IAAMC,gBAAgB,GACtB,CACC,MADD,EAEC,MAFD,EAGC,UAHD,EAIC,MAJD,EAKC,UALD,EAMC,UAND,EAOC,MAPD,EAQC,UARD,EASC,QATD,EAUC;AACA,UAXD,CADA;AAiBAC,MAAM,CAACC,OAAP,GAAiB;AAAEH,EAAAA,iBAAiB,EAAjBA,iBAAF;AAAqBC,EAAAA,gBAAgB,EAAhBA;AAArB,CAAjB","sourcesContent":["\"use strict\";\n\nconst lenientProperties =\n[\n\t\"origin\",\n\t\"searchParams\",\n\t\"toJSON\"\n];\n\nconst strictProperties =\n[\n\t\"hash\",\n\t\"host\",\n\t\"hostname\",\n\t\"href\",\n\t\"password\",\n\t\"pathname\",\n\t\"port\",\n\t\"protocol\",\n\t\"search\",\n\t// \"toString\" excluded because Object::toString exists\n\t\"username\"\n];\n\n\n\nmodule.exports = { lenientProperties, strictProperties };\n"],"file":"props.js"}package/lib/index.js000644 0000002017 3560116604 011473 0ustar00000000 000000 "use strict"; const hasToStringTag = require("has-to-string-tag-x"); const isObject = require("is-object"); const isURLSearchParams = require("is-urlsearchparams"); const {lenientProperties, strictProperties} = require("./props"); const searchParams = "searchParams"; const toStringTag = Object.prototype.toString; const urlClass = "[object URL]"; const isURL = (url, supportIncomplete=false) => { if (!isObject(url)) { return false; } else if (hasToStringTag && toStringTag.call(url)!==urlClass) { // Shimmed implementation with incorrect constructor name return false; } else if (!strictProperties.every(prop => prop in url)) { return false; } else if (supportIncomplete && searchParams in url) { return isURLSearchParams.lenient(url.searchParams); } else if (supportIncomplete) { return true; } else if (lenientProperties.every(prop => prop in url)) { return isURLSearchParams(url.searchParams); } else { return false; } }; isURL.lenient = url => isURL(url, true); module.exports = isURL; package/lib/props.js000644 0000000527 3560116604 011533 0ustar00000000 000000 "use strict"; const lenientProperties = [ "origin", "searchParams", "toJSON" ]; const strictProperties = [ "hash", "host", "hostname", "href", "password", "pathname", "port", "protocol", "search", // "toString" excluded because Object::toString exists "username" ]; module.exports = { lenientProperties, strictProperties };