is-url-superb
Advanced tools
Comparing version 3.0.0 to 4.0.0
12
index.js
'use strict'; | ||
const urlRegex = require('url-regex')({exact: true}); | ||
module.exports = url => { | ||
if (typeof url !== 'string') { | ||
module.exports = string => { | ||
if (typeof string !== 'string') { | ||
throw new TypeError('Expected a string'); | ||
} | ||
return urlRegex.test(url.trim()); | ||
try { | ||
new URL(string); // eslint-disable-line no-new | ||
return true; | ||
} catch { | ||
return false; | ||
} | ||
}; |
{ | ||
"name": "is-url-superb", | ||
"version": "3.0.0", | ||
"version": "4.0.0", | ||
"description": "Check if a string is a URL", | ||
"license": "MIT", | ||
"repository": "sindresorhus/is-url-superb", | ||
"funding": "https://github.com/sponsors/sindresorhus", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
"url": "https://sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=8" | ||
"node": ">=10" | ||
}, | ||
@@ -30,10 +31,7 @@ "scripts": { | ||
], | ||
"dependencies": { | ||
"url-regex": "^5.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "^1.4.1", | ||
"tsd": "^0.7.2", | ||
"xo": "^0.24.0" | ||
"ava": "^2.4.0", | ||
"tsd": "^0.11.0", | ||
"xo": "^0.32.0" | ||
} | ||
} |
@@ -1,8 +0,5 @@ | ||
# is-url-superb [![Build Status](https://travis-ci.org/sindresorhus/is-url-superb.svg?branch=master)](https://travis-ci.org/sindresorhus/is-url-superb) | ||
# is-url-superb [![Build Status](https://travis-ci.com/sindresorhus/is-url-superb.svg?branch=master)](https://travis-ci.com/github/sindresorhus/is-url-superb) | ||
> Check if a string is a URL | ||
Created because the [`is-url`](https://github.com/segmentio/is-url) module is too loose. This module depends on a much more comprehensive [regex](https://github.com/kevva/url-regex). | ||
## Install | ||
@@ -14,3 +11,2 @@ | ||
## Usage | ||
@@ -24,5 +20,2 @@ | ||
isUrl('//sindresorhus.com'); | ||
//=> true | ||
isUrl('unicorn'); | ||
@@ -32,5 +25,4 @@ //=> false | ||
## Related | ||
## License | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) | ||
- [is](https://github.com/sindresorhus/is) - Type check values |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
0
27
2696
26
- Removedurl-regex@^5.0.0
- Removedip-regex@4.3.0(transitive)
- Removedtlds@1.255.0(transitive)
- Removedurl-regex@5.0.0(transitive)