File tree Expand file tree Collapse file tree 5 files changed +14
-21
lines changed Expand file tree Collapse file tree 5 files changed +14
-21
lines changed Original file line number Diff line number Diff line change
1
+ github : sindresorhus
2
+ open_collective : sindresorhus
3
+ patreon : sindresorhus
4
+ custom : https://sindresorhus.com/donate
Original file line number Diff line number Diff line change 1
1
language : node_js
2
2
node_js :
3
+ - ' 12'
3
4
- ' 10'
4
- - ' 8'
Original file line number Diff line number Diff line change @@ -8,17 +8,13 @@ const statusCodes = {
8
8
} ;
9
9
10
10
module . exports = async url => {
11
- url = new URL ( url ) ;
12
- url = encodeURIComponent ( url . host ) ;
11
+ const hostname = encodeURIComponent ( ( new URL ( url ) ) . hostname ) ;
13
12
14
- const { body} = await got ( `https://isitup.org/${ url } .json` , {
15
- json : true ,
13
+ const { status_code : statusCode } = await got ( `https://isitup.org/${ hostname } .json` , {
16
14
headers : {
17
15
'user-agent' : 'https://github.com/sindresorhus/is-up'
18
16
}
19
- } ) ;
20
-
21
- const statusCode = body . status_code ;
17
+ } ) . json ( ) ;
22
18
23
19
if ( statusCode === statusCodes . invalidDomain ) {
24
20
throw new Error ( 'Invalid domain' ) ;
Original file line number Diff line number Diff line change 4
4
"description" : " Check whether a website is up or down" ,
5
5
"license" : " MIT" ,
6
6
"repository" : " sindresorhus/is-up" ,
7
+ "funding" : " https://github.com/sponsors/sindresorhus" ,
7
8
"author" : {
8
9
"name" : " Sindre Sorhus" ,
9
10
10
11
"url" : " sindresorhus.com"
11
12
},
12
13
"engines" : {
13
- "node" : " >=8 "
14
+ "node" : " >=10 "
14
15
},
15
16
"scripts" : {
16
17
"test" : " xo && ava"
30
31
" offline"
31
32
],
32
33
"dependencies" : {
33
- "got" : " ^9.3.1 "
34
+ "got" : " ^10.5.5 "
34
35
},
35
36
"devDependencies" : {
36
- "ava" : " ^1.0.0-rc.1 " ,
37
- "unique-string" : " ^1 .0.0" ,
38
- "xo" : " ^0.23.0 "
37
+ "ava" : " ^1.0.0" ,
38
+ "unique-string" : " ^2 .0.0" ,
39
+ "xo" : " ^0.25.4 "
39
40
}
40
41
}
Original file line number Diff line number Diff line change 2
2
3
3
> Check whether a website is up or down using the [ isitup.org] ( https://isitup.org ) API
4
4
5
-
6
5
## Install
7
6
8
7
```
9
8
$ npm install is-up
10
9
```
11
10
12
-
13
11
## Usage
14
12
15
13
``` js
@@ -20,15 +18,9 @@ const isUp = require('is-up');
20
18
// => true
21
19
})();
22
20
```
23
-
24
21
* Specifying the protocol is optional.*
25
22
26
23
27
24
## Related
28
25
29
26
- [ is-up-cli] ( https://github.com/sindresorhus/is-up-cli ) - CLI for this module
30
-
31
-
32
- ## License
33
-
34
- MIT © [ Sindre Sorhus] ( https://sindresorhus.com )
You can’t perform that action at this time.
0 commit comments