updated regex for img and video tag removal to fix broken cards (fingers crossed!)
This commit is contained in:
parent
6819d100d3
commit
5c78a8a491
1 changed files with 3 additions and 3 deletions
6
index.js
6
index.js
|
|
@ -133,9 +133,9 @@ export default async function now() {
|
|||
`$1${latest.image}$2`,
|
||||
)
|
||||
} else {
|
||||
// remove img tags if no image available (handle multi-line tags)
|
||||
// remove img tags if no image available (handle multi-line tags and any attribute order)
|
||||
newNow = newNow.replace(
|
||||
new RegExp(`<img[^>]*src=["']${imageId}["'][^>]*>`, 'gis'),
|
||||
new RegExp(`<img\\b[^>]*\\bsrc=["']${imageId}["'][^>]*>`, 'gis'),
|
||||
'',
|
||||
)
|
||||
// remove markdown image
|
||||
|
|
@ -154,7 +154,7 @@ export default async function now() {
|
|||
} else {
|
||||
// remove video tags if no video available
|
||||
newNow = newNow.replace(
|
||||
new RegExp(`<video[^>]*src=["']${videoId}["'][^>]*>[\\s\\S]*?</video>`, 'gi'),
|
||||
new RegExp(`<video\\b[^>]*\\bsrc=["']${videoId}["'][^>]*>[\\s\\S]*?</video>`, 'gis'),
|
||||
'',
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue