Skip to content

Commit

Permalink
Fix for GitHub custom domain
Browse files Browse the repository at this point in the history
  • Loading branch information
itiut committed Nov 25, 2016
1 parent 9097f5a commit b3df135
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
},
"devDependencies": {
"chai": "^3.5.0",
"proxyquire": "^1.7.10",
"typescript": "^1.6.2",
"vscode": "0.11.13"
},
Expand Down
2 changes: 1 addition & 1 deletion src/gitProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const providers = {
function gitProvider(remoteUrl) {
const gitUrl = gitUrlParse(remoteUrl);
for (const domain of Object.keys(providers)) {
if (domain === gitUrl.source) {
if (domain === gitUrl.resource || domain === gitUrl.source) {
return new providers[domain](gitUrl);
}
}
Expand Down
28 changes: 28 additions & 0 deletions test/gitProvider.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const querystring = require('querystring');
const expect = require('chai').expect;
const proxyquire = require('proxyquire');

const gitProvider = require('../src/gitProvider');

Expand Down Expand Up @@ -52,6 +53,33 @@ suite('gitProvider', function () {
});
});
});

suite('with custom domain', function () {
const testDomain = 'github.testdomain.com';
const remoteUrl = `https://${testDomain}/${userName}/${repoName}.git`;

const fakeVscode = {
workspace: {
getConfiguration: function () {
return {
get: function () {
return testDomain;
},
};
},
},
};
const gitProvider = proxyquire('../src/gitProvider.js', { vscode: fakeVscode });
const provider = gitProvider(remoteUrl);

suite('#webUrl(branch, filePath)', function () {
test('should return custom domain URL', function () {
const expectedUrl = `https://${testDomain}/${userName}/${repoName}/blob/${branch}${filePath}`;
const webUrl = provider.webUrl(branch, filePath);
expect(webUrl).to.equal(expectedUrl);
});
});
});
});

suite('Bitbucket', function () {
Expand Down

0 comments on commit b3df135

Please sign in to comment.