Skip to content

Commit

Permalink
Ignore case when testing scheme (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbrasetvik authored and sindresorhus committed Sep 29, 2019
1 parent 219de67 commit 17cbebc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.js
Expand Up @@ -6,11 +6,11 @@ module.exports = url => {
}

// Don't match Windows paths `c:\`
if (/^[a-z]:\\/.test(url)) {
if (/^[a-zA-Z]:\\/.test(url)) {
return false;
}

// Scheme: https://tools.ietf.org/html/rfc3986#section-3.1
// Absolute URL: https://tools.ietf.org/html/rfc3986#section-4.3
return /^[a-z][a-z\d+\-.]*:/.test(url);
return /^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(url);
};
1 change: 1 addition & 0 deletions test.js
Expand Up @@ -4,6 +4,7 @@ import isAbsoluteUrl from '.';
test('main', t => {
t.true(isAbsoluteUrl('http://sindresorhus.com'));
t.true(isAbsoluteUrl('https://sindresorhus.com'));
t.true(isAbsoluteUrl('httpS://sindresorhus.com'));
t.true(isAbsoluteUrl('file://sindresorhus.com'));
t.true(isAbsoluteUrl('mailto:someone@example.com'));
t.true(isAbsoluteUrl('data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D'));
Expand Down

0 comments on commit 17cbebc

Please sign in to comment.