wgt-node-utils 1.2.6 → 1.2.7

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.6",
3
+ "version": "1.2.7",
4
4
  "description": "WGT工具类包",
5
5
  "main": "dist/bundle.js",
6
6
  "scripts": {
package/src/index.js CHANGED
@@ -739,5 +739,34 @@ class wgtNodeUtils {
739
739
  // 转为小写后检查是否匹配
740
740
  return regex.test(path.toLowerCase());
741
741
  }
742
+
743
+ /**
744
+ * 详情页面排除非法路径:检查字符串是否包含非法文件扩展、关键词、大写字母、特殊字符
745
+ * @param {string} path - 要检查的路径字符串
746
+ * @returns {boolean} - 如果包含非法路径返回 true,否则返回 false
747
+ */
748
+
749
+ gameDetailExcludeIllegalPath = (path) => {
750
+ if (typeof path !== 'string') {
751
+ throw new Error("输入的字符串无效,请传入一个有效的字符串。");
752
+ }
753
+
754
+ // 检查非法文件扩展和敏感关键词(忽略大小写)
755
+ const illegalPatterns = /\.(php|env|xml|production|example)/i;
756
+
757
+ // 检查是否包含大写字母(排除大写字母)
758
+ const hasUpperCase = /[A-Z]/;
759
+
760
+ // 检查是否包含特殊字符(除斜杠和下划线外)
761
+ const hasSpecialChar = /[^a-zA-Z0-9/_]/;
762
+
763
+
764
+ // 任意条件满足即为非法路径
765
+ return (
766
+ illegalPatterns.test(path) || // 检测非法文件扩展或关键词
767
+ hasUpperCase.test(path) || // 检测大写字母
768
+ hasSpecialChar.test(path) // 检测特殊字符
769
+ );
770
+ }
742
771
  }
743
772
  module.exports = new wgtNodeUtils('cli_a538bc45e770d00b', 'EDK1uleQyLym6WWDISo00dwx4gssiskJ');