File tree Expand file tree Collapse file tree 3 files changed +30
-1
lines changed
Expand file tree Collapse file tree 3 files changed +30
-1
lines changed Original file line number Diff line number Diff line change 8686 },
8787 "devDependencies" : {
8888 "chai" : " ^3.5.0" ,
89+ "proxyquire" : " ^1.7.10" ,
8990 "typescript" : " ^1.6.2" ,
9091 "vscode" : " 0.11.13"
9192 },
Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ const providers = {
8181function 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 }
Original file line number Diff line number Diff line change 22
33const querystring = require ( 'querystring' ) ;
44const expect = require ( 'chai' ) . expect ;
5+ const proxyquire = require ( 'proxyquire' ) ;
56
67const 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 ( ) {
You can’t perform that action at this time.
0 commit comments