Skip to content

Commit 4f7d9ea

Browse files
authored
Merge pull request #274 from cnblogs/fix-path-replacement
fix: path replacement
2 parents cd9663a + feddc7e commit 4f7d9ea

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/service/post/post-file-map.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { postDataProvider } from '@/tree-view/provider/post-data-provider'
33
import { LocalState } from '@/ctx/local-state'
44
import { Uri } from 'vscode'
55
import { WorkspaceCfg } from '@/ctx/cfg/workspace'
6+
import { r } from '@/infra/convert/string-literal'
67

78
const validatePostFileMap = (map: PostFileMap) => map[0] >= 0 && map[1] !== ''
89
export type PostFileMap = [postId: number, filePath: string]
@@ -94,8 +95,8 @@ export namespace PostFileMapManager {
9495
const filePath = x[1]
9596
if (isUriPath(filePath) && filePath.indexOf(oldWorkspaceUri.path) >= 0)
9697
x[1] = filePath.replace(oldWorkspaceUri.path, newWorkspaceUri.path)
97-
else if (!isUriPath(filePath) && filePath.indexOf(oldWorkspaceUri.fsPath) >= 0)
98-
x[1] = filePath.replace(oldWorkspaceUri.fsPath, newWorkspaceUri.fsPath)
98+
else if (!isUriPath(filePath) && r`filePath`.indexOf(r`oldWorkspaceUri.fsPath`) >= 0)
99+
x[1] = filePath.replace(r`${oldWorkspaceUri.fsPath}`, r`${newWorkspaceUri.fsPath}`)
99100
})
100101
}
101102
}

0 commit comments

Comments
 (0)