Skip to content
This repository was archived by the owner on Feb 6, 2020. It is now read-only.

Commit 66a6a10

Browse files
committed
fix show title and preview picture on window
1 parent 095c946 commit 66a6a10

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

autoload/server/static/scripts/index.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
mkdContainer = document.getElementById('js-markdown');
99

1010
function updateTitle() {
11-
var fileName = Base64.decode(location.search.slice(1)).split('/').pop();
11+
var slash = getSlash();
12+
var fileName = Base64.decode(location.search.slice(1)).split(slash).pop();
1213
var title = document.getElementsByTagName('title')[0];
1314
title.innerHTML = fileName;
1415
}
@@ -23,12 +24,24 @@
2324
return text;
2425
}
2526

27+
function getSlash() {
28+
var platform = navigator.platform;
29+
var slash;
30+
if(/^win.*/i.test(platform)) {
31+
slash = '\\';
32+
} else {
33+
slash = '/';
34+
}
35+
return slash;
36+
}
37+
2638
function getAbsPath(base, path) {
27-
var bases = Base64.decode(base.slice(1)).split('/').slice(0, -1);
28-
var paths = path.split('/');
39+
var slash = getSlash();
40+
var bases = Base64.decode(base.slice(1)).split(slash).slice(0, -1);
41+
var paths = path.split(slash);
2942
if(/^https?:?/i.test(paths[0])) {
3043
return path;
31-
} else if(/^$/.test(paths[0])) {
44+
} else if(/^|[a-zA-Z]:\\.*$/.test(paths[0])) {
3245
return '/image?' + Base64.encode(path);
3346
} else {
3447
for(var i = 0, len = paths.length; i < len; i++) {
@@ -39,7 +52,7 @@
3952
}
4053
}
4154
}
42-
return '/image?' + Base64.encode(bases.join('/'));
55+
return '/image?' + Base64.encode(bases.join(slash));
4356
}
4457

4558
options = (function() {

0 commit comments

Comments
 (0)