Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

fix: image url extraction (#453)

Zeng19988cc0977a01c8
diff --git a/web/src/components/Memo.tsx b/web/src/components/Memo.tsx
index 2f4ff850d..dc1fc9b18 100644
--- a/web/src/components/Memo.tsx
+++ b/web/src/components/Memo.tsx
@@ -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)