Unverified Commit b04e001d authored by boojack's avatar boojack Committed by GitHub

fix: image url host missing (#623)

parent fbe7b604
...@@ -134,3 +134,9 @@ export const parseHTMLToRawText = (htmlStr: string): string => { ...@@ -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;
}
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 => { ...@@ -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 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment