mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
fix: image url host missing (#623)
This commit is contained in:
@ -134,3 +134,9 @@ export const parseHTMLToRawText = (htmlStr: string): string => {
|
|||||||
const text = tempEl.innerText;
|
const text = tempEl.innerText;
|
||||||
return text;
|
return text;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export function absolutifyLink(rel: string): string {
|
||||||
|
const anchor = document.createElement("a");
|
||||||
|
anchor.setAttribute("href", rel);
|
||||||
|
return anchor.href;
|
||||||
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { escape } from "lodash-es";
|
import { escape } from "lodash-es";
|
||||||
|
import { absolutifyLink } from "../../../helpers/utils";
|
||||||
|
|
||||||
export const IMAGE_REG = /!\[.*?\]\((.+?)\)/;
|
export const IMAGE_REG = /!\[.*?\]\((.+?)\)/;
|
||||||
|
|
||||||
@ -8,8 +9,9 @@ const renderer = (rawStr: string): string => {
|
|||||||
return rawStr;
|
return rawStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const imageUrl = absolutifyLink(escape(matchResult[1]));
|
||||||
// NOTE: Get image blob from backend to avoid CORS.
|
// NOTE: Get image blob from backend to avoid CORS.
|
||||||
return `<img class='img' src='/o/get/image?url=${escape(matchResult[1])}' />`;
|
return `<img class='img' src='/o/get/image?url=${imageUrl}' />`;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
Reference in New Issue
Block a user