-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat(webui): support images and links in README dialog #4450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
clown145
wants to merge
2
commits into
AstrBotDevs:master
Choose a base branch
from
clown145:feature/readme-image-support
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat(webui): support images and links in README dialog #4450
clown145
wants to merge
2
commits into
AstrBotDevs:master
from
clown145:feature/readme-image-support
Conversation
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
Contributor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey - 我发现了 1 个问题,并给出了一些整体性的反馈:
- 当前对 GitHub 仓库的解析和 URL 生成假定为简单的
https://github.com/owner/repo形式,并且默认分支为main;建议支持更多常见变体,例如/owner/repo/、/owner/repo.git,或带有/tree/<branch>的 URL,这样在默认分支不是main的仓库中,链接和图片也能正常工作。 parseGitHubRepoInfo使用了相对宽松的正则表达式,可能会错误解析包含点号或额外路径段的仓库名;如果收紧这部分逻辑(例如显式去掉.git并忽略尾部额外路径),可以让 URL 转换更加健壮。
给 AI 代理的提示
Please address the comments from this code review:
## Overall Comments
- 当前对 GitHub 仓库的解析和 URL 生成假定为简单的 `https://github.com/owner/repo` 形式,并且默认分支为 `main`;建议支持更多常见变体,例如 `/owner/repo/`、`/owner/repo.git`,或带有 `/tree/<branch>` 的 URL,这样在默认分支不是 `main` 的仓库中,链接和图片也能正常工作。
- `parseGitHubRepoInfo` 使用了相对宽松的正则表达式,可能会错误解析包含点号或额外路径段的仓库名;如果收紧这部分逻辑(例如显式去掉 `.git` 并忽略尾部额外路径),可以让 URL 转换更加健壮。
## Individual Comments
### Comment 1
<location> `dashboard/src/components/shared/ReadmeDialog.vue:57-60` </location>
<code_context>
});
+// 解析 GitHub 仓库信息
+function parseGitHubRepoInfo(repoUrl) {
+ if (!repoUrl) return null;
+ // 支持格式: https://github.com/user/repo 或 https://github.com/user/repo.git
+ const match = repoUrl.match(/github\.com\/([^/]+)\/([^/.]+)/);
+ if (!match) return null;
+ return { owner: match[1], repo: match[2] };
</code_context>
<issue_to_address>
**issue (bug_risk):** 用于解析 GitHub 仓库的正则会漏掉包含点号的合法仓库名,并且可能错误处理 `.git` 后缀。
`([^/.]+)` 会在遇到 `.` 或 `/` 时停止,因此像 `my.repo` 这样的仓库名会被解析为 `my`。它之所以“去掉” `.git`,只是因为在 `.` 处停止,从而将仓库名中的合法点号与 `.git` 后缀混在一起处理。更清晰的做法是捕获直到下一个 `/` 的所有内容,然后再去掉可选的 `.git` 后缀:
```js
const match = repoUrl.match(/github\.com\/([^/]+)\/([^/]+)(?:\.git)?/);
if (!match) return null;
const owner = match[1];
const repo = match[2].replace(/\.git$/, "");
return { owner, repo };
```
这样可以正确处理 `user/repo`、`user/repo.git`,以及名称中包含点号的仓库。
</issue_to_address>帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据反馈改进之后的审查。
Original comment in English
Hey - I've found 1 issue, and left some high level feedback:
- The GitHub repo parsing and URL generation assumes a simple
https://github.com/owner/reposhape and amaindefault branch; consider handling more common variants such as/owner/repo/,/owner/repo.git, or URLs with/tree/<branch>so links and images work for non-maindefault branches. parseGitHubRepoInfouses a relatively loose regex that may mis-parse repository names containing dots or additional path segments; tightening this logic (e.g., explicitly stripping.gitand ignoring trailing paths) would make the URL conversions more robust.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The GitHub repo parsing and URL generation assumes a simple `https://github.com/owner/repo` shape and a `main` default branch; consider handling more common variants such as `/owner/repo/`, `/owner/repo.git`, or URLs with `/tree/<branch>` so links and images work for non-`main` default branches.
- `parseGitHubRepoInfo` uses a relatively loose regex that may mis-parse repository names containing dots or additional path segments; tightening this logic (e.g., explicitly stripping `.git` and ignoring trailing paths) would make the URL conversions more robust.
## Individual Comments
### Comment 1
<location> `dashboard/src/components/shared/ReadmeDialog.vue:57-60` </location>
<code_context>
});
+// 解析 GitHub 仓库信息
+function parseGitHubRepoInfo(repoUrl) {
+ if (!repoUrl) return null;
+ // 支持格式: https://github.com/user/repo 或 https://github.com/user/repo.git
+ const match = repoUrl.match(/github\.com\/([^/]+)\/([^/.]+)/);
+ if (!match) return null;
+ return { owner: match[1], repo: match[2] };
</code_context>
<issue_to_address>
**issue (bug_risk):** Regex for parsing GitHub repo misses valid repo names containing dots and may mis-handle `.git` suffix.
`([^/.]+)` stops at `.` or `/`, so repos like `my.repo` are parsed as `my`. It also only strips `.git` because of the `.` stop, mixing up valid dots in repo names with the `.git` suffix. A clearer approach is to capture everything to the next `/` and then strip an optional `.git` suffix:
```js
const match = repoUrl.match(/github\.com\/([^/]+)\/([^/]+)(?:\.git)?/);
if (!match) return null;
const owner = match[1];
const repo = match[2].replace(/\.git$/, "");
return { owner, repo };
```
This correctly handles `user/repo`, `user/repo.git`, and repos with dots in the name.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area:webui
The bug / feature is about webui(dashboard) of astrbot.
size:M
This PR changes 30-99 lines, ignoring generated files.
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.
修复 README 弹窗中相对路径图片无法显示的问题,同时支持仓库内相对链接的跳转。
当 README 中使用相对路径引用图片(如
./images/screenshot.png)或其他文档(如./docs/usage.md)时,由于路径解析问题导致无法正确加载。本 PR 实现了路径自动转换功能,并复用用户已配置的 GitHub 加速代理。Modifications / 改动点
修改文件: dashboard/src/components/shared/ReadmeDialog.vue
功能实现:
https://raw.githubusercontent.com/...),支持代理加速https://github.com/.../blob/main/...)localStorage.selectedGitHubProxy)Screenshots or Test Results / 运行截图或测试结果
验证步骤:
npm run build通过 ✅Checklist / 检查清单
requirements.txt和pyproject.toml文件相应位置。/ I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations inrequirements.txtandpyproject.toml.Summary by Sourcery
增强 README 对话框,使其能够正确解析并打开针对托管在 GitHub 上的插件的仓库相对链接和图片。
新功能:
Original summary in English
Summary by Sourcery
Enhance the README dialog to correctly resolve and open repository-relative links and images for GitHub-hosted plugins.
New Features: