Fix to 'Markdown Preview of relative links drops 'host' from path' by tweing · Pull Request #95092 · microsoft/vscode
This PR fixes #93961.
Explanation
The URI class holds different information in the path property when the file was opened through a UNC location. For this fix I used the property fsPath instead of path in the onDidClickPreviewLink handler.
For a local file the URI class holds:

where as for a UNC opened file the URI class holds:

Here is an excerpt from uri.ts:
foo://example.com:8042/over/there?name=ferret#nose
\_/ \______________/\_________/ \_________/ \__/
| | | | |
scheme authority path query fragment
| _____________________|__
/ \ / \
urn:example:animal:ferret:noseTest the issue and the fix:
-
To test this issue create two md files (see below this list).
-
Open the
readme.mdfile with an UNC path like"\\server\sharedfolder\readme.md". -
Open the preview of the markdown file
readme.md. -
In the preview window, click on the
Relative link to TEST.mdlink. -
The
test.mdfile should open in the preview. Without the fix, an error message is being shown.
Test files
readme.md:
Here's a link: [Relative link to TEST.md](TEST.md)
test.md:
This is the test markdown file