Skip to content

Conversation

@yesits-me
Copy link

Changes:

  • Enhanced Regex: Updated getComputedBackgroundImages to correctly parse url() values with single quotes, double quotes, or no quotes at all.
  • Capture Groups & Backreferences: Implemented backreferences (\1) to ensure matching opening and closing quotes, preventing truncation in complex strings.
  • Improved Unescaping: Replaced specific string replacement with a global regex to handle various escaped characters returned by getComputedStyle.
  • Whitespace Handling: Added support for optional whitespace within url() functions for better compatibility with different browser engines.

Why:
The previous implementation failed on standard CSS patterns like url('...') or unquoted Data URIs, and was prone to breaking when encountering parentheses within the URL path.

Enhance getComputedBackgroundImages function to handle cases with no style and improve URL extraction.
@foooomio
Copy link
Owner

Could you give me examples of pages that would benefit from this change?

@foooomio
Copy link
Owner

According to the W3C specification, URLs should be properly escaped and enclosed in double quotes. Current versions of Chrome and Firefox operate according to the specification.

Although not yet implemented in Firefox, computedStyleMap() will put an end to this discussion.

@yesits-me yesits-me closed this Jan 29, 2026
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