Skip to content

Rewrite meta-refresh redirects in patched head to diff page URLs#1

Merged
brianpos merged 2 commits intomainfrom
copilot/patch-redirect-in-header
Apr 28, 2026
Merged

Rewrite meta-refresh redirects in patched head to diff page URLs#1
brianpos merged 2 commits intomainfrom
copilot/patch-redirect-in-header

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 27, 2026

When the "new" page's <head> contains a <meta http-equiv="refresh"> redirect, the browser follows it and navigates away from the diff page. The redirect should be intercepted and rewritten as a diff page URL, the same way body <a> links are handled by rewriteRelativeLinks.

Changes

  • rebaseHeadUrls signature — accepts oldBaseUrl in addition to newBaseUrl so it can construct full diff URLs
  • Meta-refresh rewriting — after rebasing href/src attributes, the function now also processes meta[http-equiv="refresh"] tags:
    • Resolves the redirect target against both base URLs
    • Replaces content with a ?old=…&new=… diff page URL
    • Removes the tag (with a console.warn) if URL resolution fails, preventing a broken redirect
  • Regex handles optional quotes and trailing whitespace in the content attribute (content="5; url='page.html'")
<!-- before: navigates away from the diff page -->
<meta http-equiv="refresh" content="0; url=new-location.html">

<!-- after: stays in the diff viewer -->
<meta http-equiv="refresh" content="0; url=/?old=https://old.example.com/new-location.html&new=https://new.example.com/new-location.html">

…functionality - specifically to handle the fhir IG template language redirect stuff

Co-authored-by: Copilot <copilot@github.com>
@brianpos brianpos marked this pull request as ready for review April 28, 2026 04:19
@brianpos brianpos merged commit f9b98dd into main Apr 28, 2026
1 check passed
@brianpos brianpos deleted the copilot/patch-redirect-in-header branch April 28, 2026 04:19
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.

2 participants