From fcb564b0545c5e6d69acb43758950a73304ee0cb Mon Sep 17 00:00:00 2001 From: Elio Date: Mon, 5 Sep 2022 14:55:34 +0200 Subject: [PATCH 1/2] #393 - Fix Windows file path --- CHANGELOG.md | 1 + src/commands/Preview.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 02c288dc..45455dc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ ### 🐞 Fixes - [#354](https://github.com/estruyf/vscode-front-matter/issues/354): Fix Windows file path parsing for inserting media files +- [#393](https://github.com/estruyf/vscode-front-matter/issues/393): Fix Windows file path for retrieving the preview path ## [7.3.3] - 2022-06-11 diff --git a/src/commands/Preview.ts b/src/commands/Preview.ts index e372a93d..1acf517e 100644 --- a/src/commands/Preview.ts +++ b/src/commands/Preview.ts @@ -47,8 +47,9 @@ export class Preview { let selectedFolder: ContentFolder | null = null; for (const folder of foldersWithPath) { - if (filePath.startsWith(folder.path)) { - if (!selectedFolder || selectedFolder.path.length < folder.path.length) { + const folderPath = parseWinPath(folder.path); + if (filePath.startsWith(folderPath)) { + if (!selectedFolder || selectedFolder.path.length < folderPath.length) { selectedFolder = folder; } } @@ -79,6 +80,9 @@ export class Preview { } catch (error) { slug = join(pathname, slug); } + + // Make sure there are no backslashes in the slug + slug = parseWinPath(slug); } // Create the preview webview From e4f44def472ec4d5c0bc4ca7ac34e737183ecc25 Mon Sep 17 00:00:00 2001 From: Elio Date: Mon, 5 Sep 2022 14:58:06 +0200 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f84ac25..11392b5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ - [#378](https://github.com/estruyf/vscode-front-matter/issues/378): Fix last modified update only to content in content folders - [#384](https://github.com/estruyf/vscode-front-matter/issues/384): Fix issue `title` field in sub-fields +- [#393](https://github.com/estruyf/vscode-front-matter/issues/393): Fix Windows file path for retrieving the preview path ## [8.0.1] - 2022-07-13 @@ -67,7 +68,6 @@ ### 🐞 Fixes - [#354](https://github.com/estruyf/vscode-front-matter/issues/354): Fix Windows file path parsing for inserting media files -- [#393](https://github.com/estruyf/vscode-front-matter/issues/393): Fix Windows file path for retrieving the preview path ## [7.3.3] - 2022-06-11