Skip to content

Conversation

godky
Copy link

@godky godky commented Sep 6, 2025

absolutifyURLs function calculation error when processing inline style sheets in hash mode spa. For example:

//output: url(http://www.example.com/somepath/#/a.jpg)
absolutifyURLs('url("./a.jpg")', 'http://www.example.com/somepath/#/route')

But the expected result is url(http://www.example.com/somepath/a.jpg)

…rocessing inline style sheets in hash mode spa
Copy link

changeset-bot bot commented Sep 6, 2025

🦋 Changeset detected

Latest commit: 2f0489e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 19 packages
Name Type
rrweb-snapshot Patch
rrweb Patch
rrdom Patch
rrdom-nodejs Patch
rrweb-player Patch
@rrweb/all Patch
@rrweb/replay Patch
@rrweb/record Patch
@rrweb/types Patch
@rrweb/packer Patch
@rrweb/utils Patch
@rrweb/web-extension Patch
rrvideo Patch
@rrweb/rrweb-plugin-console-record Patch
@rrweb/rrweb-plugin-console-replay Patch
@rrweb/rrweb-plugin-sequential-id-record Patch
@rrweb/rrweb-plugin-sequential-id-replay Patch
@rrweb/rrweb-plugin-canvas-webrtc-record Patch
@rrweb/rrweb-plugin-canvas-webrtc-replay Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@eoghanmurray
Copy link
Contributor

eoghanmurray commented Sep 17, 2025

Thank you so much for including updated test cases in this PR!

Using new URL needs a guard for malformed urls as it can throw an exception ... although that may be covered elsewhere in absolutifyURLs, invoking new URL is about 10x slower than the current code:
https://jsbench.me/mkmfnvg0fc/1
(assuming I've set up my benchmark correctly — see also previous note at https://github.com/rrweb-io/rrweb/blob/master/packages/rrweb-snapshot/src/snapshot.ts#L157 )

Do you think we could instead just lop off the rhs of the URL first, i.e. .split('#')[0] ?

@godky
Copy link
Author

godky commented Sep 17, 2025

Thank you so much for including updated test cases in this PR!

Using new URL needs a guard for malformed urls as it can throw an exception ... although that may be covered elsewhere in absolutifyURLs, invoking new URL is about 10x slower than the current code: https://jsbench.me/mkmfnvg0fc/1 (assuming I've set up my benchmark correctly — see also previous note at https://github.com/rrweb-io/rrweb/blob/master/packages/rrweb-snapshot/src/snapshot.ts#L157 )

Do you think we could instead just lop off the rhs of the URL first, i.e. .split('#')[0] ?

Yes, I totally agree. This site (https://jsbench.me/) is amazing.I'll finish it right away.

@godky godky requested a review from eoghanmurray September 25, 2025 14:47
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