Skip to content

Commit

Permalink
Force protocol
Browse files Browse the repository at this point in the history
Fixes #2.
  • Loading branch information
kevva committed May 26, 2015
1 parent 4318c99 commit 0c1dfaf
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ module.exports = function (url) {
throw new TypeError('Expected a string');
}

return /^(?:\w+:)?\/\//.test(url);
return /^(?:\w+:)\/\//.test(url);
};
3 changes: 3 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ var isAbsoluteUrl = require('is-absolute-url');
isAbsoluteUrl('http://sindresorhus.com/foo/bar');
//=> true

isAbsoluteUrl('//sindresorhus.com');
//=> false

isAbsoluteUrl('foo/bar');
//=> false
```
Expand Down
2 changes: 1 addition & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ it('should match absolute urls', function () {
assert(isAbsoluteUrl('http://sindresorhus.com'));
assert(isAbsoluteUrl('https://sindresorhus.com'));
assert(isAbsoluteUrl('file://sindresorhus.com'));
assert(isAbsoluteUrl('//sindresorhus.com'));
assert(!isAbsoluteUrl('//sindresorhus.com'));
assert(!isAbsoluteUrl('/foo/bar'));
assert(!isAbsoluteUrl('foo/bar'));
assert(!isAbsoluteUrl('foo'));
Expand Down

0 comments on commit 0c1dfaf

Please sign in to comment.