Repository navigation
Conversation
Plugin README files read from the local plugin directory contain relative references (e.g. docs/demo.png) that previously resolved against the dashboard origin and broke. Rewrite image src and link href against the plugin's GitHub repository — images to raw.githubusercontent.com and links to blob pages under HEAD — mirroring GitHub's own rendering. When the document is fetched from a remote URL, that URL is used as the base instead.
…docs When docUrl points at a document in a nested directory, leading-slash references (e.g. /images/logo.png) previously resolved against the document's directory instead of the origin root. Resolve them against the origin host root while keeping directory-relative references tied to the document location. GitHub-repo leading-slash handling is unchanged.
Contributor
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="dashboard/src/utils/markdownUrls.mjs" line_range="1" />
<code_context>
+const GITHUB_REPO_PATTERN = /^https?:\/\/github\.com\/([^/\s]+)\/([^/\s#?]+?)\/?$/i;
+const ABSOLUTE_URL_PATTERN = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
+
</code_context>
<issue_to_address>
**README links point to nonexistent paths**
When a plugin’s GitHub repository URL ends in `.git`, `GITHUB_REPO_PATTERN` captures `.git` as part of the repository name, so `resolveRelativeUrls` builds raw and blob paths under `repo.git/HEAD` and README images and links fail.
Strip an optional `.git` suffix from the captured repository name before building the raw and blob bases.
</issue_to_address>
### Comment 2
<location path="dashboard/src/utils/markdownUrls.mjs" line_range="1" />
<code_context>
+const GITHUB_REPO_PATTERN = /^https?:\/\/github\.com\/([^/\s]+)\/([^/\s#?]+?)\/?$/i;
+const ABSOLUTE_URL_PATTERN = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
+
</code_context>
<issue_to_address>
**Repository links stay dashboard-relative**
When a plugin’s repository URL uses `www.github.com` or an SCP-style GitHub locator, `GITHUB_REPO_PATTERN` does not match these forms, so `resolveRelativeUrls` leaves `rawBase` and `blobBase` empty and README images and links resolve against the dashboard origin.
Extend the repository URL parsing to recognize `www.github.com` and SCP-style GitHub locators.
</issue_to_address>Sourcery assessment
Approval pending. 2 findings to address first.
Blocking findings: dashboard/src/utils/markdownUrls.mjs:1, dashboard/src/utils/markdownUrls.mjs:1
3 of 5 tasks
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #9950.
Replaces #9948 with the same relative-URL fix, updated against upstream
masterat48ba71ad7. The original PR was closed due to conflicts and inactivity; its conflict is now resolved, but GitHub rejected reopening it through both the CLI and REST API.Plugin README and changelog content loaded from the local plugin directory previously resolved relative image and document URLs against the dashboard origin, causing broken images and 404 links. Resolve these references against the plugin repository or the URL from which the document was fetched before rendering.
Modifications / 改动点
resolveRelativeUrlsindashboard/src/utils/markdownUrls.mjs. For local GitHub plugin documents, images resolve againstraw.githubusercontent.com/<owner>/<repo>/HEAD/and links againstgithub.com/<owner>/<repo>/blob/HEAD/.ReadmeDialog.vueandPluginDetailPage.vue. Remotely fetched market documents use their source URL; leading-slash references resolve against that URL's origin..git,www.github.com, and SCP-stylegit@github.com:owner/repoforms. The diff against master contains only the original four files.Affected paths: locally installed plugin README/changelog dialogs, installed plugin details, and remote market README/changelog content. Regression checks cover repository-relative and host-root-relative paths, unchanged external URLs and fragments, and unsupported repository sources. No new dependencies, API changes, or user-facing text are introduced.
Documentation: checked the relevant plugin and WebUI instructions in
docs/zhanddocs/en. No documentation or screenshot updates are needed because navigation, page structure, labels, and workflows are unchanged. This is a bug fix; the new-feature discussion item below is not applicable.Screenshots or Test Results / 运行截图或测试结果
Verification was performed on the merged branch on the host machine:
Resolver tests cover GitHub images and links, leading-slash paths, remote document directory and origin resolution, unchanged fragments/absolute/protocol-relative URLs, unsupported repositories, and missing sources. A manual browser smoke test was not performed.
Checklist / 检查清单
😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
/ 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。
👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
/ 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”。
📚 I checked the affected WebUI instructions and screenshots in
docs/zhanddocs/enagainst the changed navigation, page structure, and labels, and updated them in this PR (or explained why no documentation update is needed). For renamed, moved, or merged entry points, I included an old entry → new entry mapping in the documentation and changelog./ 我已对照变化后的 WebUI 入口、页面结构和术语,核对并在本 PR 中更新
docs/zh和docs/en的相关操作说明与截图(或说明无需更新文档的原因)。入口改名、移动或合并时,已在文档和 changelog 中补充 旧入口 → 新入口 对照。🤓 I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in
requirements.txtandpyproject.toml./ 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到
requirements.txt和pyproject.toml文件相应位置。😮 My changes do not introduce malicious code.
/ 我的更改没有引入恶意代码。
Summary by Sourcery
Fix relative URLs in rendered plugin documentation so images and links point to the correct repository or fetched document source.
Bug Fixes:
Enhancements:
Tests: