Skip to content

Commit

Permalink
Merge pull request #308 from cnblogs/replace-hash
Browse files Browse the repository at this point in the history
fix: use chinese hash in filename
  • Loading branch information
cnblogs-dudu authored Oct 6, 2024
2 parents 33de969 + 106a11b commit f2dc187
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vscode-cnb",
"displayName": "博客园 cnblogs 客户端",
"description": "Cnblogs Client For VSCode",
"version": "0.0.1",
"version": "1.8.58",
"license": "LICENSE.txt",
"preview": false,
"publisher": "cnblogs",
Expand Down
3 changes: 3 additions & 0 deletions src/cmd/post-list/post-pull.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ export async function postPull(input: InputType, showConfirm = true, mute = fals
}

let uriPath = PostFileMapManager.getFilePath(post.id)

if (uriPath != null && uriPath.indexOf('#') < 0 && post.title.indexOf('#') >= 0) uriPath = undefined

let fileUri: Uri
if (uriPath == null) {
fileUri = PostFileMapManager.buildLocalPostFileUri(post)
Expand Down
3 changes: 2 additions & 1 deletion src/service/post/post-file-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export namespace PostFileMapManager {
export function buildLocalPostFileUri(post: Post, appendToFileName = ''): Uri {
const workspaceUri = WorkspaceCfg.getWorkspaceUri()
const ext = `${post.isMarkdown ? 'md' : 'html'}`
let postTitle = sanitizeFileName(post.title)
let postTitle = post.title.replace(/#/g, '#')
postTitle = sanitizeFileName(postTitle)
if (/\.\d+$/.test(postTitle)) postTitle += '_'
return Uri.joinPath(workspaceUri, `${postTitle}${appendToFileName}.${post.id}.${ext}`)
}
Expand Down

0 comments on commit f2dc187

Please sign in to comment.