mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-31 11:28:51 +00:00
14
projects/sandbox/src/utils.ts
Normal file
14
projects/sandbox/src/utils.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
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);
|
||||
};
|
Reference in New Issue
Block a user