Skip to content

fix: Only relocate index.html references to package files - #1084

Merged
MartinZikmund merged 1 commit into
unoplatform:mainfrom
mikernet:dev/mikernet/index-html-relocation
Oct 8, 2026
Merged

MartinZikmund merged 1 commit into
unoplatform:mainfrom
mikernet:dev/mikernet/index-html-relocation

Conversation

@mikernet

Copy link
Copy Markdown
Contributor

Fixes #1083

What is the current behavior?

The index.html rewrite prefixes every double-quoted reference starting with ./ or with the web app base path with the package folder. With the / base path Uno.Sdk applies by default, every site-absolute reference in a custom page is rewritten: /favicon.ico, /api/status and href="/" all end up under package_<hash>/.

What is the new behavior?

GenerateIndexHtml() builds the set of package-relative paths from the static web content deployed to package_<hash>/ and only relocates references whose path is in that set, via a new IndexHtmlHelper.RelocatePackageReferences. Query strings and fragments are preserved. Everything else is left as written.

The apple-touch-icon link generated from the PWA manifest previously depended on the blind rewrite (it was emitted as <base>./pwa-images/... and then rewritten). It is now emitted with the icon's package path directly, using the same relocation as the manifest's icons entries.

Spec: specs/006-index-html-reference-relocation/spec.md. Doc: features-additional-files.md.

Validation

  • Given_IndexHtmlHelper unit tests: relocation under ./, / and /app/, query string and fragment preservation, and the untouched cases above. Unit test project passes, 56 tests.
  • Default template: Uno.Wasm.Tests.Fingerprint built with /app/ and a PWA manifest produces a byte-identical index.html before and after the change.
  • Custom index.html with /favicon.ico, fetch("/api/status"), an external script and href="/": only ./require.js, ./uno-bootstrap.js and the injected stylesheets point into the package folder; the rest is unchanged.
  • Uno.Wasm.Sample.RayTracer (PWA with icons under ./pwa-images/): the apple-touch-icon link resolves to ./package_<hash>/pwa-images/ios/ios-appicon-1024-1024.png, and the manifest icon entries are unchanged.

Copilot AI lite review requested due to automatic review settings September 21, 2026 14:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Generated uno-config.js is omitted from the package reference set, leaving references to it unresolved.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

Fixes index.html reference relocation so only package-deployed files are rewritten, preserving root and external references.

Changes:

  • Adds selective relocation with query and fragment preservation.
  • Updates PWA icon path handling.
  • Adds tests, specification, and documentation.
File Summary
src/​Uno.Wasm.Bootstrap/​ShellTask.cs Builds package references and updates PWA icon handling.
src/​Uno.Wasm.Bootstrap/​IndexHtmlHelper.cs Implements selective reference relocation.
src/​Uno.Wasm.Bootstrap.UnitTests/​Given_IndexHtmlHelper.cs Tests relocation and untouched references.
specs/​006-index-html-reference-relocation/​spec.md Documents requirements and validation.
doc/​features-additional-files.md Documents custom index behavior.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/Uno.Wasm.Bootstrap/ShellTask.cs Resolved
Copilot AI review requested due to automatic review settings September 21, 2026 15:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

No unresolved blocking issues were identified.

Review effort: Lite
Findings: None

Resolved since last review (1)

@mikernet

mikernet commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

The Packages Windows failure here is not related to this change. The only failing task is Authenticode Sign Packages: the sign tool rejects an empty Azure tenant id for every package because PR builds don't receive the signing secrets. Every other job (Linux, Windows and macOS tests, docs checks, and the package build itself) passes.

The signing step is meant to be skipped on pull requests, but its condition in build/ci/stage-build-packages.yml is indented under the task's parameters, so the pipeline ignores it. #1080 moves that line to the task level and is the only one of my open PRs with a green Packages Windows job. Once #1080 is in, a re-run against master will clear this.

The index.html rewrite prefixed every double-quoted reference starting
with ./ or with the web app base path with the package folder. With
the / base path that Uno.Sdk applies by default, this rewrote every
site-absolute reference in a custom page: /favicon.ico, /api/status
and even href="/" ended up under package_<hash>/.

Only references whose path is a file deployed to the package folder
are relocated now; query strings and fragments are preserved. The
apple-touch-icon link is emitted with the icon's package path directly
instead of depending on the rewrite.
Copilot AI lite review requested due to automatic review settings October 8, 2026 08:21
@MartinZikmund
MartinZikmund force-pushed the dev/mikernet/index-html-relocation branch from 46884d2 to 5b0fb60 Compare October 8, 2026 08:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Relative base paths such as ./app/ need corrected matching order and a regression test.

0 open findings

🧠 Review effort: Lite


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

@MartinZikmund

Copy link
Copy Markdown
Member

🤖 Addressed PR comments up to this point

@MartinZikmund
MartinZikmund merged commit 90f7000 into unoplatform:main Oct 8, 2026
14 checks passed
@mergify

mergify Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

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.

index.html rewrite relocates every absolute reference into the package folder

3 participants