Skip to content

Commit 52c344d

Browse files
committed
fix: filter markdown video href
Signed-off-by: Innei <i@innei.in>
1 parent 3cc24dd commit 52c344d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

apps/core/src/utils/pic.util.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import getColors from 'get-image-colors'
22
import { marked } from 'marked'
33

4+
const isVideoExts = ['.mp4', '.webm', '.ogg', '.mov', '.avi', '.flv', '.mkv']
45
export const pickImagesFromMarkdown = (text: string) => {
56
const ast = marked.lexer(text)
67
const images = [] as string[]
78
function pickImage(node: any) {
89
if (node.type === 'image') {
10+
if (isVideoExts.some((ext) => node.href.endsWith(ext))) {
11+
return
12+
}
913
images.push(node.href)
1014
return
1115
}

0 commit comments

Comments
 (0)