fix: image url extraction (#453)

fix: image-url-extraction

Co-authored-by: boojack <stevenlgtm@gmail.com>
This commit is contained in:
Zeng1998 2022-11-12 21:25:50 +08:00 committed by GitHub
parent 0809ec8c72
commit 8cc0977a01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -165,7 +165,14 @@ const Memo: React.FC<Props> = (props: Props) => {
if (currImgUrl) {
// use regex to get all image urls from memo content
const imageUrls = memo.content.match(/!\[.*?\]\((.*?)\)/g)?.map((item) => item.match(/\((.*?)\)/)?.[1] ?? "") ?? [];
const imageUrls =
memo.content.match(/!\[.*?\]\((.*?)\)/g)?.map(
(item) =>
item
.match(/\((.*?)\)/g)
?.slice(-1)[0]
.slice(1, -1) ?? ""
) ?? [];
showPreviewImageDialog(
imageUrls,
imageUrls.findIndex((item) => item === currImgUrl)