Skip to content

Commit

Permalink
fix path of href on Windows (fix #37)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysd committed Oct 26, 2017
1 parent d8562c9 commit 2f1ead8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions renderer/markdown-preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ function openMarkdownLink(event: MouseEvent) {
path = path.slice(0, hash_idx);
}

if (process.platform === 'win32' && path[0] === '/') {
// Chromium convert relative path of 'href' into absolute path.
// But on Windows 'foo/bar' is converted into 'file:///C:/foo/bar'.
// C:/foo/bar is correct. So strip first '/' here (#37).
path = path.slice(1);
}

if (element_env.openMarkdownDoc) {
element_env.openMarkdownDoc(path, event.ctrlKey || event.metaKey);
} else {
Expand Down

0 comments on commit 2f1ead8

Please sign in to comment.