Skip to content

Commit b3df135

Browse files
committed
Fix for GitHub custom domain
1 parent 9097f5a commit b3df135

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
},
8787
"devDependencies": {
8888
"chai": "^3.5.0",
89+
"proxyquire": "^1.7.10",
8990
"typescript": "^1.6.2",
9091
"vscode": "0.11.13"
9192
},

src/gitProvider.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ const providers = {
8181
function gitProvider(remoteUrl) {
8282
const gitUrl = gitUrlParse(remoteUrl);
8383
for (const domain of Object.keys(providers)) {
84-
if (domain === gitUrl.source) {
84+
if (domain === gitUrl.resource || domain === gitUrl.source) {
8585
return new providers[domain](gitUrl);
8686
}
8787
}

test/gitProvider.test.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const querystring = require('querystring');
44
const expect = require('chai').expect;
5+
const proxyquire = require('proxyquire');
56

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

@@ -52,6 +53,33 @@ suite('gitProvider', function () {
5253
});
5354
});
5455
});
56+
57+
suite('with custom domain', function () {
58+
const testDomain = 'github.testdomain.com';
59+
const remoteUrl = `https://${testDomain}/${userName}/${repoName}.git`;
60+
61+
const fakeVscode = {
62+
workspace: {
63+
getConfiguration: function () {
64+
return {
65+
get: function () {
66+
return testDomain;
67+
},
68+
};
69+
},
70+
},
71+
};
72+
const gitProvider = proxyquire('../src/gitProvider.js', { vscode: fakeVscode });
73+
const provider = gitProvider(remoteUrl);
74+
75+
suite('#webUrl(branch, filePath)', function () {
76+
test('should return custom domain URL', function () {
77+
const expectedUrl = `https://${testDomain}/${userName}/${repoName}/blob/${branch}${filePath}`;
78+
const webUrl = provider.webUrl(branch, filePath);
79+
expect(webUrl).to.equal(expectedUrl);
80+
});
81+
});
82+
});
5583
});
5684

5785
suite('Bitbucket', function () {

0 commit comments

Comments
 (0)