Skip to content

Commit cf08d53

Browse files
committed
Add alt to image tag
1 parent 1920ba6 commit cf08d53

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

crawler/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ class Crawler {
120120
}
121121

122122
async getImage(body) {
123-
const regex = /!\[[^\]]*\]\((.*?.png|.*?.jpeg|.*?.jpg|.*?.webp|.*?.svg|.*?.gif|.*?.tiff)\s*("(?:.*[^"])")?\s*\)|!\[[^\]]*\]\((.*?)\s*("(?:.*[^"])")?\s*\)/g;
123+
const regex = /!\[([^\]]*)\]\((.*?.png|.*?.jpeg|.*?.jpg|.*?.webp|.*?.svg|.*?.gif|.*?.tiff)\s*("(?:.*[^"])")?\s*\)|!\[[^\]]*\]\((.*?)\s*("(?:.*[^"])")?\s*\)/g;
124124

125-
body = body.replace(regex, (_, url) => {
125+
body = body.replace(regex, (_, alt, url) => {
126126
if (!url) return;
127127

128128
const filename = url.replace(/\/\s*$/,'').split('/').slice(-2).join('-').trim();
@@ -136,7 +136,7 @@ class Crawler {
136136
.then(resp => resp.data.pipe(fs.createWriteStream(path)))
137137
.catch(e => console.error(`⚠️ 이미지를 다운 받는데 오류가 발생했습니다 / url = ${url} , e = ${e}`));
138138

139-
return `![](/images/${filename})`;
139+
return `![${alt}](/images/${filename})`;
140140
});
141141

142142
return body;

0 commit comments

Comments
 (0)