Skip to content

Commit 4b138ca

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

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

links.js

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,27 @@ function createLink(linkData) {
1515
let link = '';
1616

1717
if (linkData.dir) {
18-
19-
link += '/' +
20-
encodeURI(
21-
linkData.dir.join('/')
22-
);
23-
24-
25-
if (linkData.file) {
26-
27-
link += '/' +
28-
encodeURI(
29-
linkData.file.name
30-
);
31-
18+
19+
[user, repo, contents] = linkData.dir;
20+
21+
if (user && repo) {
22+
23+
link += '/' + encodeURIComponent(user) +
24+
'/' + encodeURIComponent(repo);
25+
26+
if (contents) {
27+
28+
link += '/' + encodeURIComponent(contents);
29+
30+
}
31+
32+
33+
if (linkData.file) {
34+
35+
link += '/' + encodeURIComponent(linkData.file.name);
36+
37+
}
38+
3239
}
3340

3441
}

0 commit comments

Comments
 (0)