Skip to content

🐛 Set serialized iframe base URL for realtive URLs using <base>#519

Merged
wwilsman merged 3 commits intomasterfrom
rd/set-rel-urls
Aug 23, 2021
Merged

🐛 Set serialized iframe base URL for realtive URLs using <base>#519
wwilsman merged 3 commits intomasterfrom
rd/set-rel-urls

Conversation

@Robdel12
Copy link
Copy Markdown
Contributor

@Robdel12 Robdel12 commented Aug 20, 2021

What is this?

Discovered in #507, the regex that was used to parse and covert relative URLs was quite expensive. In that specific issue, it would hang the browser indefinitely.

Instead of trying to use a regex to serialize the full URL into the document, we can skip all of that serialization work by adding a <base> element to the iframes <head>. This will set the base URL for all relative paths within the iframe.

Closes #507

@Robdel12 Robdel12 added the 🐛 bug Something isn't working label Aug 20, 2021
@Robdel12 Robdel12 requested a review from wwilsman August 20, 2021 22:36
Copy link
Copy Markdown
Contributor

@wwilsman wwilsman left a comment

Choose a reason for hiding this comment

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

Two small changes (I made them for you since you're on vacation).

  1. We don't actually have to use the body element to get the baseURI, we can just pull it off the element passed in (the frame document's root element).
  2. There was some leftover test setup for the removed test. I also changed the tests to use the respective iframe's baseURI.

🎮

@wwilsman wwilsman merged commit ba8ffd0 into master Aug 23, 2021
@wwilsman wwilsman deleted the rd/set-rel-urls branch August 23, 2021 21:01
samarsault pushed a commit that referenced this pull request Mar 3, 2023
Bumps [@percy/core](https://github.com/percy/cli/tree/HEAD/packages/core) from 1.3.1 to 1.5.1.
- [Release notes](https://github.com/percy/cli/releases)
- [Commits](https://github.com/percy/cli/commits/v1.5.1/packages/core)

---
updated-dependencies:
- dependency-name: "@percy/core"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Serializing relative URL in iframes: Percysnapshot hang on iframe page with map

2 participants