Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Require Node.js 12.20 and move to ESM
- Loading branch information
1 parent
26088da
commit 3ced641
Showing
7 changed files
with
24 additions
and
31 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,23 @@ | ||
'use strict'; | ||
const got = require('got'); | ||
import got from 'got'; | ||
|
||
const statusCodes = { | ||
isUp: 1, | ||
isDown: 2, | ||
invalidDomain: 3 | ||
invalidDomain: 3, | ||
}; | ||
|
||
module.exports = async url => { | ||
export default async function isUp(url) { | ||
const hostname = encodeURIComponent((new URL(url)).hostname); | ||
|
||
const {status_code: statusCode} = await got(`https://isitup.org/${hostname}.json`, { | ||
headers: { | ||
'user-agent': 'https://github.com/sindresorhus/is-up' | ||
} | ||
'user-agent': 'https://github.com/sindresorhus/is-up', | ||
}, | ||
}).json(); | ||
|
||
if (statusCode === statusCodes.invalidDomain) { | ||
throw new Error('Invalid domain'); | ||
} | ||
|
||
return statusCode === statusCodes.isUp; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters