Skip to content

fix(minecraft): 修复中文环境下 Minecraft 更新日志 Wiki 链接无效 [Composer]#3228

Closed
cbglzt-alt wants to merge 1 commit into
PCL-Community:devfrom
cbglzt-alt:fix/issue-3223
Closed

fix(minecraft): 修复中文环境下 Minecraft 更新日志 Wiki 链接无效 [Composer]#3228
cbglzt-alt wants to merge 1 commit into
PCL-Community:devfrom
cbglzt-alt:fix/issue-3223

Conversation

@cbglzt-alt

@cbglzt-alt cbglzt-alt commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • 修复中文 UI 下点击「更新日志」时浏览器打开但不跳转的问题
  • GetWikiUrlSuffix 的中文路径补上 /w/ 前缀,使 URL 与 GetWikiBaseUrl() 正确拼接

Root cause

  • feat(i18n): 非中国大陆地区禁用地区特供功能 #3074 引入多语言 Wiki 支持后,McUpdateLogShow 改为 GetWikiBaseUrl() + GetWikiUrlSuffix() 拼接
  • 非中文后缀以 /w/... 开头,中文后缀却返回 Java版{version}(无 /w/
  • 拼接结果如 https://zh.minecraft.wikiJava版1.21.1 为无效 URL,Shell 仅启动浏览器进程而不导航

Reproduction (before fix)

  1. 使用 Debug 编译的 PCL CE(dev 分支,中文 UI)
  2. 进入「下载」→ 任意 Minecraft 版本 → 点击右侧「更新日志」按钮
  3. Chrome 打开但不跳转,且每次弹出账号选择(像全新实例)

Verification (after fix)

  • 浏览器正确跳转到 https://zh.minecraft.wiki/w/Java版…
  • Chrome 复用已有 Profile,不再重复询问账号
  • Debug 构建通过

Test plan

  • 本地 Debug 构建
  • 点击更新日志按钮,确认 Wiki 页面正常打开

Close #3223

Made with Cursor

Summary by Sourcery

Bug Fixes:

  • 确保中文 Minecraft Wiki 的 URL 后缀包含 /w/ 前缀,以便更新日志链接在浏览器中打开正确的页面。
Original summary in English

Summary by Sourcery

Bug Fixes:

  • Ensure Chinese Minecraft Wiki URL suffixes include the /w/ prefix so update log links open the correct page in browsers.

PCL-Community#3074 引入多语言 Wiki 后,中文后缀缺少 /w/ 路径前缀,
拼接出无效 URL 导致浏览器无法跳转。

Close PCL-Community#3223

Co-authored-by: Cursor <cursoragent@cursor.com>
@pcl-ce-automation pcl-ce-automation Bot added 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查 size: XS PR 大小评估:微型 labels Jun 21, 2026
@sourcery-ai

sourcery-ai Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

通过确保 Wiki URL 后缀始终包含 /w/ 前缀并使用基于序数的 Contains 检查,本 PR 修复了中文区域的 Minecraft 更新日志 Wiki URL,使其可以与 Wiki 基础 URL 正确拼接,并生成可正常导航的有效 URL。

GetWikiUrlSuffix 逻辑更新的流程图

flowchart TD
    A[GetWikiUrlSuffix gameVersion] --> B[GetLanguageCode]
    B --> C{langCode starts with zh}
    C -- no --> D[return /w/Special:Search?search=Java Edition formattedVersion]
    C -- yes --> E{gameVersion.Contains w with StringComparison.Ordinal}
    E -- yes --> F[return /w/formattedVersion]
    E -- no --> G[return /w/Java版formattedVersion]
Loading

文件级变更

Change Details Files
确保中文 Minecraft Wiki URL 后缀包含 /w/ 前缀,以便它们能拼接成有效的 URL。
  • 修改 GetWikiUrlSuffix 的中文分支,使其在快照版和正式版中都返回带有 /w/ 前缀的路径。
  • 将版本字符串的 Contains 检查更新为使用基于序数比较(ordinal)的重载,以获得一致性和正确性。
PCL.Core/Minecraft/McFormatter.cs

针对关联 Issue 的评估

Issue Objective Addressed Explanation
#3223 确保在 2.15.0 Beta 3 分支中,在中文环境下点击 Minecraft 版本“更新日志”按钮时,能够正确打开浏览器并跳转到相应的 Minecraft Wiki 更新日志页面。

可能相关的 Issue


Tips and commands

与 Sourcery 交互

  • 触发新审核: 在 pull request 中评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审核评论。
  • 从审核评论生成 GitHub issue: 在某条审核评论下回复,要求 Sourcery 从该评论创建 issue。你也可以在审核评论下回复 @sourcery-ai issue 来从该评论创建 issue。
  • 生成 pull request 标题: 在 pull request 标题的任意位置写上 @sourcery-ai 即可随时生成标题。你也可以在 pull request 中评论 @sourcery-ai title 来(重新)生成标题。
  • 生成 pull request 摘要: 在 pull request 正文中任意位置写上 @sourcery-ai summary,即可在该位置生成 PR 摘要。你也可以在 pull request 中评论 @sourcery-ai summary 来在任意时间(重新)生成摘要。
  • 生成审核者指南: 在 pull request 中评论 @sourcery-ai guide,即可随时(重新)生成审核者指南。
  • 一次性处理所有 Sourcery 评论: 在 pull request 中评论 @sourcery-ai resolve,即可标记解决所有 Sourcery 评论。当你已经处理完所有评论且不想再看到它们时,这会很有用。
  • 关闭所有 Sourcery 审核: 在 pull request 中评论 @sourcery-ai dismiss,即可关闭所有现有的 Sourcery 审核。尤其适用于你想从头开始一次新的审核时——别忘了再评论 @sourcery-ai review 来触发新的审核!

自定义你的体验

访问你的控制面板 来:

  • 启用或禁用审核功能,例如 Sourcery 生成的 pull request 摘要、审核者指南等。
  • 更改审核语言。
  • 添加、删除或编辑自定义审核指令。
  • 调整其他审核设置。

获取帮助

Original review guide in English
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Fixes the Minecraft update log wiki URL for Chinese locale by ensuring the wiki URL suffix always includes the /w/ prefix and uses an ordinal contains check, so it concatenates correctly with the wiki base URL and results in a valid navigable URL.

Flow diagram for GetWikiUrlSuffix logic update

flowchart TD
    A[GetWikiUrlSuffix gameVersion] --> B[GetLanguageCode]
    B --> C{langCode starts with zh}
    C -- no --> D[return /w/Special:Search?search=Java Edition formattedVersion]
    C -- yes --> E{gameVersion.Contains w with StringComparison.Ordinal}
    E -- yes --> F[return /w/formattedVersion]
    E -- no --> G[return /w/Java版formattedVersion]
Loading

File-Level Changes

Change Details Files
Ensure Chinese Minecraft wiki URL suffixes include the /w/ prefix so they concatenate into valid URLs.
  • Change the Chinese branch of GetWikiUrlSuffix to return /w/-prefixed paths for both snapshot and release versions.
  • Update the version string Contains check to use the ordinal comparison overload for consistency and correctness.
PCL.Core/Minecraft/McFormatter.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#3223 Ensure that in the 2.15.0 Beta 3 branch, clicking the Minecraft version "更新日志" (changelog) button correctly opens and navigates the browser to the proper Minecraft Wiki changelog page in Chinese environments.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我发现了 1 个问题,并给出了一些整体性的反馈:

  • 调用 gameVersion.Contains('w', StringComparison.Ordinal) 并不是 .NET 中标准的 string API 签名;如果这不是你们代码库里的扩展方法,就应该改成 gameVersion.Contains("w", StringComparison.Ordinal),或者改回 Contains('w'),以避免编译/运行时问题。
  • 使用 gameVersion.Contains('w', …) 这个启发式逻辑来决定是否添加 /w/ 前缀比较脆弱(例如,任何包含字母 w 的版本字符串都会被当成完整的 wiki 路径);建议使用更健壮的检查方式,比如检测是否已有 /w/ 前缀,或匹配已知的 URL 模式。
供 AI Agents 使用的提示
Please address the comments from this code review:

## Overall Comments
- The call `gameVersion.Contains('w', StringComparison.Ordinal)` is not a standard `string` API signature in .NET; if this isn’t an extension method in your codebase, it should be changed to `gameVersion.Contains("w", StringComparison.Ordinal)` or back to `Contains('w')` to avoid compilation/runtime issues.
- The heuristic `gameVersion.Contains('w', …)` to decide whether to prepend `/w/` is quite brittle (e.g., any version string containing the letter `w` will be treated as a full wiki path); consider a more robust check, such as detecting an existing `/w/` prefix or matching a known URL pattern instead.

## Individual Comments

### Comment 1
<location path="PCL.Core/Minecraft/McFormatter.cs" line_range="54" />
<code_context>
             return $"/w/Special:Search?search={Uri.EscapeDataString($"Java Edition {formattedVersion}")}";

-        if (gameVersion.Contains('w')) return formattedVersion;
+        if (gameVersion.Contains('w', StringComparison.Ordinal)) return $"/w/{formattedVersion}";

-        return "Java版" + formattedVersion;
</code_context>
<issue_to_address>
**issue (bug_risk):** The `Contains` overload used here is invalid for a `char` and `StringComparison` combination.

This overload won’t compile because `string.Contains(char)` doesn’t take a `StringComparison`. Use the string overload instead, e.g. `gameVersion.Contains("w", StringComparison.Ordinal)`, or drop `StringComparison` and keep `gameVersion.Contains('w')` if ordinal comparison isn’t required.
</issue_to_address>

Sourcery 对开源项目免费——如果你觉得我们的评审有帮助,请考虑分享 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据这些反馈改进未来的评审。
Original comment in English

Hey - I've found 1 issue, and left some high level feedback:

  • The call gameVersion.Contains('w', StringComparison.Ordinal) is not a standard string API signature in .NET; if this isn’t an extension method in your codebase, it should be changed to gameVersion.Contains("w", StringComparison.Ordinal) or back to Contains('w') to avoid compilation/runtime issues.
  • The heuristic gameVersion.Contains('w', …) to decide whether to prepend /w/ is quite brittle (e.g., any version string containing the letter w will be treated as a full wiki path); consider a more robust check, such as detecting an existing /w/ prefix or matching a known URL pattern instead.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The call `gameVersion.Contains('w', StringComparison.Ordinal)` is not a standard `string` API signature in .NET; if this isn’t an extension method in your codebase, it should be changed to `gameVersion.Contains("w", StringComparison.Ordinal)` or back to `Contains('w')` to avoid compilation/runtime issues.
- The heuristic `gameVersion.Contains('w', …)` to decide whether to prepend `/w/` is quite brittle (e.g., any version string containing the letter `w` will be treated as a full wiki path); consider a more robust check, such as detecting an existing `/w/` prefix or matching a known URL pattern instead.

## Individual Comments

### Comment 1
<location path="PCL.Core/Minecraft/McFormatter.cs" line_range="54" />
<code_context>
             return $"/w/Special:Search?search={Uri.EscapeDataString($"Java Edition {formattedVersion}")}";

-        if (gameVersion.Contains('w')) return formattedVersion;
+        if (gameVersion.Contains('w', StringComparison.Ordinal)) return $"/w/{formattedVersion}";

-        return "Java版" + formattedVersion;
</code_context>
<issue_to_address>
**issue (bug_risk):** The `Contains` overload used here is invalid for a `char` and `StringComparison` combination.

This overload won’t compile because `string.Contains(char)` doesn’t take a `StringComparison`. Use the string overload instead, e.g. `gameVersion.Contains("w", StringComparison.Ordinal)`, or drop `StringComparison` and keep `gameVersion.Contains('w')` if ordinal comparison isn’t required.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

return $"/w/Special:Search?search={Uri.EscapeDataString($"Java Edition {formattedVersion}")}";

if (gameVersion.Contains('w')) return formattedVersion;
if (gameVersion.Contains('w', StringComparison.Ordinal)) return $"/w/{formattedVersion}";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): 这里使用的 Contains 重载对 charStringComparison 的组合来说是无效的。

这个重载无法通过编译,因为 string.Contains(char) 不接受 StringComparison。请改用字符串重载,例如 gameVersion.Contains("w", StringComparison.Ordinal),或者如果不需要按 Ordinal 比较,就去掉 StringComparison 并保持 gameVersion.Contains('w')

Original comment in English

issue (bug_risk): The Contains overload used here is invalid for a char and StringComparison combination.

This overload won’t compile because string.Contains(char) doesn’t take a StringComparison. Use the string overload instead, e.g. gameVersion.Contains("w", StringComparison.Ordinal), or drop StringComparison and keep gameVersion.Contains('w') if ordinal comparison isn’t required.

@LuLu-ling

Copy link
Copy Markdown
Member

#3227 装车了

@LuLu-ling LuLu-ling closed this Jun 21, 2026
@pcl-ce-automation pcl-ce-automation Bot removed 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查 size: XS PR 大小评估:微型 labels Jun 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[C#]: 无法查看Minecraft更新日志

2 participants