@aspan-corporation/ac-shared 1.2.34 → 1.2.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/utils/diary.js +7 -2
- package/package.json +1 -1
package/lib/utils/diary.js
CHANGED
|
@@ -144,10 +144,15 @@ export const diaryPreview = (markdown) => {
|
|
|
144
144
|
/** Extract the media keys of photos embedded as `` in the body. */
|
|
145
145
|
export const extractEmbeddedPhotoKeys = (markdown) => {
|
|
146
146
|
const keys = new Set();
|
|
147
|
-
|
|
147
|
+
// Two destination forms (CommonMark): angle-bracketed `<…>` — used for keys
|
|
148
|
+
// with spaces, and which may also contain ")" (e.g. "image (2).jpg") — or a
|
|
149
|
+
// bare URL up to the first ")". The angle form is captured in group 1, the
|
|
150
|
+
// bare form in group 2; the bare form must stop at ")" so it can't swallow a
|
|
151
|
+
// parenthesised key, which is exactly why such keys use the angle form.
|
|
152
|
+
const re = /!\[[^\]]*\]\(\s*(?:<([^>]*)>|([^)\s]+))\s*\)/g;
|
|
148
153
|
let m;
|
|
149
154
|
while ((m = re.exec(markdown)) !== null) {
|
|
150
|
-
const key = m[1].trim();
|
|
155
|
+
const key = (m[1] ?? m[2] ?? "").trim();
|
|
151
156
|
// Only treat library media keys as photo links (ignore external URLs).
|
|
152
157
|
if (key && !/^https?:\/\//i.test(key))
|
|
153
158
|
keys.add(key);
|