Skip to content

Commit 9201ecd

Browse files
committed
Fix special characters error
1 parent 1c1c01b commit 9201ecd

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

crawler/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,12 @@ class Crawler {
9090
}
9191

9292
async writePost(post) {
93-
const excludedChar = ['\\', '/', ':' ,'*' ,'?' ,'"' ,'<' ,'>' ,'|'];
93+
const excludedChar = ['\\\\', '/', ':' ,'\\*' ,'\\?' ,'"' ,'<' ,'>' ,'\\|'];
9494
let title = post.title;
9595

9696
for (const char of excludedChar) {
97-
title = title.replace(char, '');
97+
const re = new RegExp(char, 'g');
98+
title = title.replace(re, '');
9899
}
99100

100101
const path = join('backup', 'content', `${title}.md`);

0 commit comments

Comments
 (0)