Skip to content

Commit 47a2234

Browse files
committed
[Fix]修复Mod文件名带.会无法正常提取干净名称
1 parent cb45b77 commit 47a2234

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

src/main.cpp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,19 +110,24 @@ std::string getCleanModName(const std::string& fullFileName) {
110110

111111
// 2. 迭代移除版本号、Minecraft版本、加载器后缀和通用标签
112112
// 匹配模式:
113-
// - `[-_+\\s]` 作为分隔符 (新增了 `\\s` 匹配空格)
114-
// - 后跟 `v?` (可选的 'v')
115-
// - 接着是数字和点 (`[0-9.]+`),后面可以有字母数字、下划线、连字符、加号、点
116-
// - 或 `mc` 后跟数字和点
117-
// - 或精确匹配的加载器/阶段名称 (如 forge, fabric, snapshot, beta, alpha, universal, all)
113+
// - `[-_+\\s.]` 作为分隔符 (允许连字符、下划线、加号、空格、点)
114+
// - 后跟:
115+
// - `v?[0-9]+(?:[\\._\\-][0-9a-zA-Z_+-]+)*` (标准版本号,如 -1.0.0, +1.20.1, -v1.0.0-beta)
116+
// - `mc[0-9]+(?:\\.[0-9]+)*` (Minecraft 版本号,如 -mc1.16.5)
117+
// - `forge|fabric|quilt|neoforge|rift|liteloader` (精确匹配的加载器名称)
118+
// - `snapshot|pre|rc|beta|alpha` (精确匹配的发布阶段)
119+
// - `universal|all` (精确匹配的通用标签)
118120
// - `$` 确保匹配发生在字符串的末尾
119121
std::regex suffix_regex(
120-
"[-_+\\s](?:v?[0-9]+(?:[\\._\\-][0-9a-zA-Z_+-]+)*" // 标准版本号,如 -1.0.0, +1.20.1, -v1.0.0-beta
121-
"|mc[0-9]+(?:\\.[0-9]+)*" // Minecraft 版本号,如 -mc1.16.5
122-
"|forge|fabric|quilt|neoforge|rift|liteloader" // 精确匹配的加载器名称
123-
"|snapshot|pre|rc|beta|alpha" // 精确匹配的发布阶段
124-
"|universal|all" // 精确匹配的通用标签
125-
")$", std::regex_constants::icase // 忽略大小写匹配,并确保匹配到字符串末尾
122+
"[-_+\\s.]" // Delimiters: hyphen, underscore, plus, space, DOT
123+
"(?:" // Start non-capturing group for the patterns to remove
124+
"v?[0-9]+(?:[\\._\\-][0-9a-zA-Z_+-]+)*" // Standard version, e.g., -1.0.0, +1.20.1, -v1.0.0-beta
125+
"|mc[0-9]+(?:\\.[0-9]+)*" // Minecraft version, e.g., -mc1.16.5
126+
"|forge|fabric|quilt|neoforge|rift|liteloader" // Exact loader names
127+
"|snapshot|pre|rc|beta|alpha" // Exact release stages
128+
"|universal|all" // Exact common tags
129+
")" // End non-capturing group for patterns
130+
"$", std::regex_constants::icase // Anchor to the end, ignore case
126131
);
127132

128133
// 循环移除匹配的后缀,直到没有更多匹配

0 commit comments

Comments
 (0)