Skip to content

Fix relative URL resolution in HTML page reports#4609

Open
davidarny wants to merge 2 commits intositespeedio:mainfrom
davidarny:fix-html-report-base-href
Open

Fix relative URL resolution in HTML page reports#4609
davidarny wants to merge 2 commits intositespeedio:mainfrom
davidarny:fix-html-report-base-href

Conversation

@davidarny
Copy link
Copy Markdown

Summary

Fix relative URL resolution in generated HTML page reports by adding a <base> tag for per-page summary/run pages.

This makes page reports work whether they are opened as:

  • /pages/example_com/path
  • /pages/example_com/path/
  • /pages/example_com/path/index.html

Without this, relative URLs like data/browsertime.har.gz and data/screenshots/... can resolve to the wrong parent path when the page is opened without a trailing slash.

Problem

Generated page report HTML uses relative paths such as:

  • data/browsertime.har.gz
  • data/screenshots/...
  • ./1.html
  • metrics.html

When a report page is opened at a slashless directory URL, the browser resolves those relative paths against the parent path, which can produce 404s for the HAR and screenshots. The waterfall then stays loading forever because the fetch/decompression never succeeds.

Fix

  • Add optional baseHref support in the shared HTML layout template.
  • Pass baseHref for URL summary and URL run pages from htmlBuilder.js.

The computed base href points to the generated page directory, so all existing relative URLs continue to work correctly.

Related

Fixes #4608

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 42ed39b46b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/plugins/html/htmlBuilder.js Outdated
Comment thread lib/plugins/html/htmlBuilder.js Outdated
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.

HTML report page summary breaks when opened without trailing slash (waterfall/screenshots 404)

1 participant