Skip to content

Commit 0113b92

Browse files
committed
Add replace code when Unallowed Special Character included
1 parent 0340a59 commit 0113b92

File tree

3 files changed

+46
-7
lines changed

3 files changed

+46
-7
lines changed

app.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@ program.parse(process.argv);
1414
!fs.existsSync('./backup/content') && fs.mkdirSync('./backup/content');
1515
!fs.existsSync('./backup/images') && fs.mkdirSync('./backup/images');
1616

17-
18-
1917
const crawler = new Crawler(program.username, {
2018
delay: program.delay || 0,
21-
});
19+
});
2220

23-
console.log('📙 백업을 시작합니다 / velog-backup')
24-
crawler.parse()
21+
console.log('📙 백업을 시작합니다 / velog-backup');
22+
crawler.parse();

crawler/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,14 @@ class Crawler {
7979
}
8080

8181
async writePost(post) {
82-
const path = join('backup', 'content', `${post.title.replace(/\//g, ' ').replace(':','-')}.md`);
82+
const excludedChar = ['\\', '/', ':' ,'*' ,'?' ,'"' ,'<' ,'>' ,'|'];
83+
let title = post.title;
84+
85+
for (const char of excludedChar) {
86+
title = title.replace(char, '');
87+
}
88+
89+
const path = join('backup', 'content', `${title}.md`);
8390

8491
post.body = '---\n'
8592
+ `title: "${post.title}"\n`

package-lock.json

Lines changed: 35 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)