mirror of
https://github.com/labring/FastGPT.git
synced 2025-10-14 23:22:22 +00:00
fix: question guide prompt save & sub route image (#5672)
* fix: question guide prompt save & sub route image * fix markdown
This commit is contained in:
@@ -35,10 +35,14 @@ export const getImageBase64 = async (url: string) => {
|
||||
|
||||
export const addEndpointToImageUrl = (text: string) => {
|
||||
const baseURL = process.env.FE_DOMAIN;
|
||||
const subRoute = process.env.NEXT_PUBLIC_BASE_URL || '';
|
||||
if (!baseURL) return text;
|
||||
// 匹配 /api/system/img/xxx.xx 的图片链接,并追加 baseURL
|
||||
return text.replace(
|
||||
/(?<!https?:\/\/[^\s]*)(?:\/api\/system\/img\/[^\s.]*\.[^\s]*)/g,
|
||||
(match) => `${baseURL}${match}`
|
||||
const regex = new RegExp(
|
||||
`(?<!https?:\\/\\/[^\\s]*)(?:${subRoute}\\/api\\/system\\/img\\/[^\\s.]*\\.[^\\s]*)`,
|
||||
'g'
|
||||
);
|
||||
// 匹配 ${subRoute}/api/system/img/xxx.xx 的图片链接,并追加 baseURL
|
||||
return text.replace(regex, (match) => {
|
||||
return `${baseURL}${match}`;
|
||||
});
|
||||
};
|
||||
|
Reference in New Issue
Block a user