mirror of
https://github.com/usememos/memos.git
synced 2025-02-21 21:57:47 +01:00
fix: image url host missing (#623)
This commit is contained in:
parent
fbe7b604ef
commit
b04e001db1
@ -134,3 +134,9 @@ export const parseHTMLToRawText = (htmlStr: string): string => {
|
||||
const text = tempEl.innerText;
|
||||
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 { absolutifyLink } from "../../../helpers/utils";
|
||||
|
||||
export const IMAGE_REG = /!\[.*?\]\((.+?)\)/;
|
||||
|
||||
@ -8,8 +9,9 @@ const renderer = (rawStr: string): string => {
|
||||
return rawStr;
|
||||
}
|
||||
|
||||
const imageUrl = absolutifyLink(escape(matchResult[1]));
|
||||
// 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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user