From 17cbebc9096e33e67e2e845d670782200456f32c Mon Sep 17 00:00:00 2001 From: Alex Brasetvik Date: Sun, 29 Sep 2019 07:30:37 +0200 Subject: [PATCH] Ignore case when testing scheme (#9) --- index.js | 4 ++-- test.js | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index c5752f8..25dca66 100644 --- a/index.js +++ b/index.js @@ -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); }; diff --git a/test.js b/test.js index 448c4ca..f68537b 100644 --- a/test.js +++ b/test.js @@ -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'));