wgt-node-utils 1.2.3 → 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.js +1 -1
- package/package.json +1 -1
- package/src/index.js +23 -11
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -375,7 +375,11 @@ class wgtNodeUtils {
|
|
|
375
375
|
useSendFeiShu = false
|
|
376
376
|
} = options;
|
|
377
377
|
try {
|
|
378
|
-
let feiShuContent =
|
|
378
|
+
let feiShuContent = `{"text":"<b>前端容器node报错</b>\\ncomponent: ${components}\\nenv: ${ENV}\\nmesssage: ${message}"}`
|
|
379
|
+
if (usePageUrl && req) {
|
|
380
|
+
const pageUrl = new URL(req.originalUrl, `${req.protocol}://${req.get('host')}`).href;
|
|
381
|
+
feiShuContent = `{"text":"<b>前端容器node报错</b>\\ncomponent: ${components}\\nenv: ${ENV}\\npageUrl: ${decodeURIComponent(pageUrl)}\\nmesssage: ${message}"}`
|
|
382
|
+
}
|
|
379
383
|
if (!err) {
|
|
380
384
|
console.warn(`============${new Date().toLocaleString()}===========`);
|
|
381
385
|
console.warn(message);
|
|
@@ -385,21 +389,12 @@ class wgtNodeUtils {
|
|
|
385
389
|
console.error(`${message} [${err.config.method}]: ${err.config.url}`);
|
|
386
390
|
console.error(`request: {params: ${JSON.stringify(err.config.params)}, data: ${ err.config.data ? JSON.stringify(err.config.data) : ''}}`);
|
|
387
391
|
console.error(`response: ${JSON.stringify( this.safeStringify(err.response))}`);
|
|
388
|
-
|
|
389
|
-
if (usePageUrl && req) {
|
|
390
|
-
const pageUrl = new URL(req.originalUrl, `${req.protocol}://${req.get('host')}`).href;
|
|
391
|
-
feiShuContent = `{"text":"<b>前端容器node报错</b>\\ncomponent: ${components}\\nenv: ${ENV}\\npageUrl: ${decodeURIComponent(pageUrl)}\\nmesssage: ${message}"}`
|
|
392
|
-
}
|
|
392
|
+
|
|
393
393
|
this.sendFeiShu(feiShuContent, receive_id, useSendFeiShu);
|
|
394
394
|
|
|
395
395
|
} else {
|
|
396
396
|
console.error(`============${new Date().toLocaleString()}===========`);
|
|
397
397
|
console.error(message);
|
|
398
|
-
feiShuContent = `{"text":"<b>前端容器node报错</b>\\ncomponent: ${components}\\nenv: ${ENV}\\nmesssage: ${message}"}`
|
|
399
|
-
if (usePageUrl && req) {
|
|
400
|
-
const pageUrl = new URL(req.originalUrl, `${req.protocol}://${req.get('host')}`).href;
|
|
401
|
-
feiShuContent = `{"text":"<b>前端容器node报错</b>\\ncomponent: ${components}\\nenv: ${ENV}\\npageUrl: ${decodeURIComponent(pageUrl)}\\nmesssage: ${message}"}`
|
|
402
|
-
}
|
|
403
398
|
this.sendFeiShu(feiShuContent, receive_id, useSendFeiShu);
|
|
404
399
|
}
|
|
405
400
|
} catch (e) {
|
|
@@ -727,5 +722,22 @@ class wgtNodeUtils {
|
|
|
727
722
|
};
|
|
728
723
|
}
|
|
729
724
|
};
|
|
725
|
+
|
|
726
|
+
/**
|
|
727
|
+
* 排除非法路径:检查字符串是否包含非法文件扩展或关键词
|
|
728
|
+
* @param {string} path - 要检查的路径字符串
|
|
729
|
+
* @returns {boolean} - 如果包含非法路径返回 true,否则返回 false
|
|
730
|
+
*/
|
|
731
|
+
|
|
732
|
+
excludeIllegalPath = (path) => {
|
|
733
|
+
if (typeof path !== 'string') {
|
|
734
|
+
throw new Error("输入的字符串无效,请传入一个有效的字符串。");
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
// 预定义的正则表达式(忽略大小写匹配敏感关键词)
|
|
738
|
+
const regex = /\.(php|env|xml|production|example)/i;
|
|
739
|
+
// 转为小写后检查是否匹配
|
|
740
|
+
return regex.test(path.toLowerCase());
|
|
741
|
+
}
|
|
730
742
|
}
|
|
731
743
|
module.exports = new wgtNodeUtils('cli_a538bc45e770d00b', 'EDK1uleQyLym6WWDISo00dwx4gssiskJ');
|