Skip to content

Commit 26ad87b

Browse files
committed
Update links.js
1 parent 4b138ca commit 26ad87b

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

links.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,31 @@ function createLink(linkData) {
1616

1717
if (linkData.dir) {
1818

19-
[user, repo, contents] = linkData.dir;
19+
const [user, repo, contents] = linkData.dir;
20+
let [repoName, branch] = repo.split(':');
2021

2122
if (user && repo) {
2223

23-
link += '/' + encodeURIComponent(user) +
24-
'/' + encodeURIComponent(repo);
24+
const modRepo = modifiedRepos[user + '/' + repoName];
25+
26+
if (modRepo && modRepo.branches
27+
&& modRepo.branches.length === 1) {
28+
29+
branch = '';
30+
31+
} else {
32+
33+
branch = ':' + branch;
34+
35+
}
36+
37+
38+
link += '/' + encodeURI(user) +
39+
'/' + encodeURI(repo + branch);
2540

2641
if (contents) {
2742

28-
link += '/' + encodeURIComponent(contents);
43+
link += '/' + encodeURI(contents);
2944

3045
}
3146

0 commit comments

Comments
 (0)