Skip to content

Commit 663eb59

Browse files
committed
Require Node.js 10
1 parent c07eb48 commit 663eb59

File tree

6 files changed

+20
-26
lines changed

6 files changed

+20
-26
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
language: node_js
22
node_js:
3+
- '14'
4+
- '12'
35
- '10'
4-
- '8'

index.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
'use strict';
2-
const urlRegex = require('url-regex')({exact: true});
32

4-
module.exports = url => {
5-
if (typeof url !== 'string') {
3+
module.exports = string => {
4+
if (typeof string !== 'string') {
65
throw new TypeError('Expected a string');
76
}
87

9-
return urlRegex.test(url.trim());
8+
try {
9+
new URL(string); // eslint-disable-line no-new
10+
return true;
11+
} catch {
12+
return false;
13+
}
1014
};

license

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
3+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
44

55
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:
66

package.json

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
"description": "Check if a string is a URL",
55
"license": "MIT",
66
"repository": "sindresorhus/is-url-superb",
7+
"funding": "https://github.com/sponsors/sindresorhus",
78
"author": {
89
"name": "Sindre Sorhus",
910
"email": "sindresorhus@gmail.com",
10-
"url": "sindresorhus.com"
11+
"url": "https://sindresorhus.com"
1112
},
1213
"engines": {
13-
"node": ">=8"
14+
"node": ">=10"
1415
},
1516
"scripts": {
1617
"test": "xo && ava && tsd"
@@ -27,12 +28,9 @@
2728
"check",
2829
"is"
2930
],
30-
"dependencies": {
31-
"url-regex": "^5.0.0"
32-
},
3331
"devDependencies": {
34-
"ava": "^1.4.1",
35-
"tsd": "^0.7.2",
36-
"xo": "^0.24.0"
32+
"ava": "^2.4.0",
33+
"tsd": "^0.11.0",
34+
"xo": "^0.32.0"
3735
}
3836
}

readme.md

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
# is-url-superb [![Build Status](https://travis-ci.org/sindresorhus/is-url-superb.svg?branch=master)](https://travis-ci.org/sindresorhus/is-url-superb)
1+
# 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)
22

33
> Check if a string is a URL
44
5-
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).
6-
7-
85
## Install
96

107
```
118
$ npm install is-url-superb
129
```
1310

14-
1511
## Usage
1612

1713
```js
@@ -20,14 +16,10 @@ const isUrl = require('is-url-superb');
2016
isUrl('https://sindresorhus.com');
2117
//=> true
2218

23-
isUrl('//sindresorhus.com');
24-
//=> true
25-
2619
isUrl('unicorn');
2720
//=> false
2821
```
2922

23+
## Related
3024

31-
## License
32-
33-
MIT © [Sindre Sorhus](https://sindresorhus.com)
25+
- [is](https://github.com/sindresorhus/is) - Type check values

test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import test from 'ava';
22
import isUrl from '.';
33

44
test('main', t => {
5-
t.true(isUrl('//sindresorhus.com'));
65
t.true(isUrl('https://sindresorhus.com'));
76
t.false(isUrl('abc https://sindresorhus.com'));
87
});

0 commit comments

Comments
 (0)