mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-29 09:44:47 +00:00
15 lines
434 B
TypeScript
15 lines
434 B
TypeScript
export const replaceSensitiveText = (text: string) => {
|
|
// 1. http link
|
|
text = text.replace(/(?<=https?:\/\/)[^\s]+/g, 'xxx');
|
|
// 2. nx-xxx 全部替换成xxx
|
|
text = text.replace(/ns-[\w-]+/g, 'xxx');
|
|
|
|
return text;
|
|
};
|
|
|
|
export const getErrText = (err: any, def = '') => {
|
|
const msg: string = typeof err === 'string' ? err : err?.message ?? def;
|
|
msg && console.log('error =>', msg);
|
|
return replaceSensitiveText(msg);
|
|
};
|