Skip to content

Commit 01da4b1

Browse files
authoredNov 6, 2019
fix(giturl): use githubusercontent for raw url (#194)
fixes #193
1 parent 3a3e5e8 commit 01da4b1

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed
 

‎src/GitUrl.js

+3
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ class GitUrl {
119119
if (MATCH_IP.test(this.hostname)) {
120120
return `${protocol}://${this.host}/${type}`;
121121
}
122+
if (type === 'raw' && this.host === 'github.com') {
123+
return `${protocol}://raw.githubusercontent.com`;
124+
}
122125
return `${protocol}://${type}.${this.host}`;
123126
}
124127

‎test/giturl.test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,8 @@ describe('GitUrl from object tests', () => {
454454
assert.equal(url.repo, 'repository');
455455
assert.equal(url.path, '');
456456
assert.equal(url.ref, '');
457-
assert.equal(url.raw, 'https://raw.github.com/company/repository/master');
458-
assert.equal(url.rawRoot, 'https://raw.github.com');
457+
assert.equal(url.raw, 'https://raw.githubusercontent.com/company/repository/master');
458+
assert.equal(url.rawRoot, 'https://raw.githubusercontent.com');
459459
assert.equal(url.apiRoot, 'https://api.github.com');
460460
assert.equal(url.isLocal, false);
461461
assert.equal(url.toString(), 'https://github.com/company/repository.git');
@@ -484,8 +484,8 @@ describe('GitUrl from object tests', () => {
484484
assert.equal(url.repo, 'repository');
485485
assert.equal(url.path, '');
486486
assert.equal(url.ref, '');
487-
assert.equal(url.raw, 'https://raw.github.com/company/repository/master');
488-
assert.equal(url.rawRoot, 'https://raw.github.com');
487+
assert.equal(url.raw, 'https://raw.githubusercontent.com/company/repository/master');
488+
assert.equal(url.rawRoot, 'https://raw.githubusercontent.com');
489489
assert.equal(url.apiRoot, 'https://api.github.com');
490490
assert.equal(url.isLocal, false);
491491
assert.equal(url.toString(), 'https://github.com/company/repository.git');

0 commit comments

Comments
 (0)
Please sign in to comment.