Skip to content

Commit

Permalink
Accept full URLs as input (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
realabbas committed Feb 12, 2020
1 parent 8c65ef6 commit a0848a0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const statusCodes = {
};

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

const {body} = await got(`https://isitup.org/${url}.json`, {
json: true,
Expand Down
2 changes: 1 addition & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ test('down', async t => {
});

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

0 comments on commit a0848a0

Please sign in to comment.