From 3349575ea7a9fa70af72f24e1ca4507ac9948a9b Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Fri, 6 Jul 2018 16:01:48 -0700 Subject: [PATCH] feat(all): Support www. prefixes on hostnames Fixes: #32 --- index.js | 2 +- test/bitbucket.js | 1 + test/github.js | 2 ++ test/gitlab.js | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 9055ab1..2766788 100644 --- a/index.js +++ b/index.js @@ -58,7 +58,7 @@ function fromUrl (giturl, opts) { project = decodeURIComponent(shortcutMatch[3]) defaultRepresentation = 'shortcut' } else { - if (parsed.host !== gitHostInfo.domain) return + if (parsed.host !== gitHostInfo.domain && parsed.host.replace(/^www[.]/, '') !== gitHostInfo.domain) return if (!gitHostInfo.protocols_re.test(parsed.protocol)) return if (!parsed.path) return var pathmatch = gitHostInfo.pathmatch diff --git a/test/bitbucket.js b/test/bitbucket.js index 98334d3..8f08a5e 100644 --- a/test/bitbucket.js +++ b/test/bitbucket.js @@ -21,6 +21,7 @@ test('fromUrl(bitbucket url)', function (t) { } require('./lib/standard-tests')(verify, 'bitbucket.org', 'bitbucket') + require('./lib/standard-tests')(verify, 'www.bitbucket.org', 'bitbucket') t.end() }) diff --git a/test/github.js b/test/github.js index 6ea141a..2749bad 100644 --- a/test/github.js +++ b/test/github.js @@ -39,5 +39,7 @@ test('fromUrl(github url)', function (t) { require('./lib/standard-tests')(verify, 'github.com', 'github') + require('./lib/standard-tests')(verify, 'www.github.com', 'github') + t.end() }) diff --git a/test/gitlab.js b/test/gitlab.js index 7a5fda3..1f22e7a 100644 --- a/test/gitlab.js +++ b/test/gitlab.js @@ -21,6 +21,7 @@ test('fromUrl(gitlab url)', function (t) { } require('./lib/standard-tests')(verify, 'gitlab.com', 'gitlab') + require('./lib/standard-tests')(verify, 'www.gitlab.com', 'gitlab') t.end() })