From cb368e4ab9ef845d1d38ffe3db2d088bc46af38f Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Thu, 2 Apr 2015 08:40:49 +0000 Subject: [PATCH] fix scm detection for specific git urls --- node_modules/c9/scm_url_parse.js | 22 ++++++++++++++++++---- node_modules/c9/scm_url_parse_test.js | 10 ++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/node_modules/c9/scm_url_parse.js b/node_modules/c9/scm_url_parse.js index 30b7da60..f7789bdd 100644 --- a/node_modules/c9/scm_url_parse.js +++ b/node_modules/c9/scm_url_parse.js @@ -31,17 +31,31 @@ define(function(require, exports, module) { parsed.hostname && parsed.slashes && parsed.pathname - ) + ) { + var scm; + var provider = providers[parsed.hostname] || defaultProvider; + switch (provider) { + case "github": + scm = "git"; + break; + case "bitbucket": + scm = parsed.pathname.match(/\.git$/) ? "git": "hg"; + break; + default: + scm = parsed.pathname.match(/\.git$/) ? "git": "hg"; + } return { protocol: parsed.protocol, - scm: parsed.pathname.match(/\.git$/) ? "git": "hg", - provider: providers[parsed.hostname] || defaultProvider, + scm: scm, + provider: provider, auth: parsed.auth || "", hostname: parsed.hostname, pathname: parsed.pathname.replace(/^\/+/, ""), full: url }; - else + } + else { return null; + } }; }); \ No newline at end of file diff --git a/node_modules/c9/scm_url_parse_test.js b/node_modules/c9/scm_url_parse_test.js index 34fb3367..44151967 100644 --- a/node_modules/c9/scm_url_parse_test.js +++ b/node_modules/c9/scm_url_parse_test.js @@ -64,6 +64,16 @@ describe(__filename, function(){ assert.equal(url.pathname, "fjakobs/juhu"); done(); }); + + it("should parse github URL without .git", function(done) { + var url = parse("https://github.com/arunoda/meteor-streams"); + assert.equal(url.protocol, "https:"); + assert.equal(url.scm, "git"); + assert.equal(url.provider, "github"); + assert.equal(url.hostname, "github.com"); + assert.equal(url.pathname, "arunoda/meteor-streams"); + done(); + }); }); }); \ No newline at end of file