wgt-node-utils 1.2.4 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wgt-node-utils",
3
- "version": "1.2.4",
3
+ "version": "1.2.6",
4
4
  "description": "WGT工具类包",
5
5
  "main": "dist/bundle.js",
6
6
  "scripts": {
package/src/index.js CHANGED
@@ -722,5 +722,22 @@ class wgtNodeUtils {
722
722
  };
723
723
  }
724
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
+ }
725
742
  }
726
743
  module.exports = new wgtNodeUtils('cli_a538bc45e770d00b', 'EDK1uleQyLym6WWDISo00dwx4gssiskJ');