Skip to content

fix: stop crashing on protocol-relative image source URLs - #2365

Closed
uuzzrm wants to merge 1 commit into
felladrin:mainfrom
uuzzrm:fix/image-source-url
Closed

fix: stop crashing on protocol-relative image source URLs#2365
uuzzrm wants to merge 1 commit into
felladrin:mainfrom
uuzzrm:fix/image-source-url

Conversation

@uuzzrm

@uuzzrm uuzzrm commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Fixes #2363

new URL(sourceUrl).hostname throws on protocol-relative (//www.youtube.com/embed/...) and relative (/images/...) source URLs, and since the lightbox slides are rebuilt on every render, a single bad result swapped the whole image section for the "Error loading search results" alert.

Video results come in as SearXNG iframe_src, which engines routinely return protocol-relative (YouTube embeds especially), and some image engines return relative img_src values too, so this isn't an exotic case.

Swapped the label to the existing getHostname() helper — it already falls back to the raw string for unparseable URLs and is what this same component uses for the aria-label and the "Visit" link.

Added a regression test with a protocol-relative and a relative source URL; before the change the render threw TypeError: Invalid URL.

Verified with vitest run, biome check, and tsc.

new URL() without a base throws on //host/... and /path/... source URLs, and the lightbox slides are rebuilt on every render, so a single result with such a URL replaced the whole image section with the error alert. Image and video engines return these routinely (iframe_src from SearXNG video results, relative img_src values on some image engines).

Use the getHostname() helper the component already uses for the aria-label and the Visit link, which falls back to the raw string when parsing fails. Regression test covers both a protocol-relative and a relative source URL.
@uuzzrm uuzzrm closed this Aug 15, 2026
@uuzzrm uuzzrm reopened this Aug 15, 2026
@uuzzrm uuzzrm closed this Aug 15, 2026
@uuzzrm

uuzzrm commented Aug 15, 2026

Copy link
Copy Markdown
Contributor Author

Closing this in favor of #2367 - same fix, and that one covers both protocol-relative and relative URLs in the tests. Keeping a single PR for #2363.

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.

Image results section crashes when a result's source URL is protocol-relative or relative

1 participant