From f6e7db19f81388006db8b54d18af1ed6fc7dd0d3 Mon Sep 17 00:00:00 2001 From: Nick Dunets Date: Wed, 5 Aug 2020 20:09:57 +1200 Subject: [PATCH] Normalize slashes in file url to make it work for Windows --- src/docsBrowser.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/docsBrowser.ts b/src/docsBrowser.ts index bf80385b..51fe5536 100644 --- a/src/docsBrowser.ts +++ b/src/docsBrowser.ts @@ -85,11 +85,13 @@ export namespace DocsBrowser { function processLink(ms: MarkedString): string | MarkdownString { function transform(s: string): string { - return s.replace(/\[(.+)\]\((file:.+\/doc\/.+\.html#?.*)\)/gi, (all, title, path) => { - const encoded = encodeURIComponent(JSON.stringify({ title, path })); - const cmd = 'command:haskell.showDocumentation?' + encoded; - return `[${title}](${cmd})`; - }); + // normalize slashes from windows paths and replace file url with show doc command + return s.replace(/\\/gi, '/') + .replace(/\[(.+)\]\((file:.+\/doc\/.+\.html#?.*)\)/gi, (all, title, path) => { + const encoded = encodeURIComponent(JSON.stringify({ title, path })); + const cmd = 'command:haskell.showDocumentation?' + encoded; + return `[${title}](${cmd})`; + }); } if (typeof ms === 'string') { return transform(ms as string);