Skip to content

fix: resolve asset URLs relative to document.baseURI - #122

Merged
Gaubee merged 1 commit into
mainfrom
fix/base-url-icons
Dec 26, 2025
Merged

Gaubee merged 1 commit into
mainfrom
fix/base-url-icons

Conversation

@Gaubee

@Gaubee Gaubee commented Dec 26, 2025

Copy link
Copy Markdown
Contributor

问题

在 GitHub Pages 部署时,以 / 开头的图标路径(如 /icons/ethereum/chain.svg)会解析为根路径 https://bioforestchain.github.io/icons/...,而不是正确的 https://bioforestchain.github.io/KeyApp/webapp/icons/...。

解决方案

  1. 创建 resolveAssetUrl 工具函数,基于 document.baseURI 解析相对路径
  2. 在 IconProvidersWrapper 中预处理链配置,将 icon 和 tokenIconBase 路径解析为完整 URL

改动

  • src/lib/asset-url.ts: 新增 URL 解析工具函数
  • src/lib/asset-url.test.ts: 工具函数单元测试
  • src/frontend-main.tsx: 在 Provider 层应用路径解析

- Add resolveAssetUrl utility to handle relative paths for GitHub Pages deployment
- Update IconProvidersWrapper to resolve chain icon and token icon base URLs
- Fixes icons showing as /icons/... instead of /KeyApp/webapp/icons/... on gh-pages
@Gaubee
Gaubee force-pushed the fix/base-url-icons branch from bb7ae73 to 6e8dfd1 Compare December 26, 2025 07:56
@Gaubee
Gaubee merged commit d484e58 into main Dec 26, 2025
5 checks passed
@Gaubee
Gaubee deleted the fix/base-url-icons branch January 4, 2026 07:23
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.

1 participant