Skip to content

Commit a0848a0

Browse files
authored
Accept full URLs as input (#9)
1 parent 8c65ef6 commit a0848a0

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ const statusCodes = {
88
};
99

1010
module.exports = async url => {
11-
url = url.replace(/^(?:https?:)?\/\//, '');
12-
url = encodeURIComponent(url);
11+
url = new URL(url);
12+
url = encodeURIComponent(url.host);
1313

1414
const {body} = await got(`https://isitup.org/${url}.json`, {
1515
json: true,

test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ test('down', async t => {
1111
});
1212

1313
test('invalid domain', async t => {
14-
await t.throwsAsync(isUp('unicorn'), 'Invalid domain');
14+
await t.throwsAsync(isUp('unicorn'), 'Invalid URL: unicorn');
1515
});

0 commit comments

Comments
 (0)