diff --git a/client/components/Search/Results/Graphical/ImageResultsList.test.tsx b/client/components/Search/Results/Graphical/ImageResultsList.test.tsx
index d0aabb31..6da75dfc 100644
--- a/client/components/Search/Results/Graphical/ImageResultsList.test.tsx
+++ b/client/components/Search/Results/Graphical/ImageResultsList.test.tsx
@@ -109,4 +109,60 @@ describe("ImageResultsList", () => {
expect(slide).toBeInTheDocument();
expect(slide?.getAttribute("style") ?? "").not.toContain("transition");
});
+
+ it("opens the lightbox when a source URL is protocol-relative", async () => {
+ const user = userEvent.setup();
+ render(
+
+
+ ,
+ );
+
+ await user.click(
+ await screen.findByRole("button", {
+ name: "Open image preview: Protocol-relative image",
+ }),
+ );
+
+ const dialog = await screen.findByRole("dialog");
+ expect(dialog.textContent).toContain(
+ "Source: //cdn.example.com/protocol-relative.jpg",
+ );
+ });
+
+ it("opens the lightbox when a source URL is relative", async () => {
+ const user = userEvent.setup();
+ render(
+
+
+ ,
+ );
+
+ await user.click(
+ await screen.findByRole("button", {
+ name: "Open image preview: Relative image",
+ }),
+ );
+
+ const dialog = await screen.findByRole("dialog");
+ expect(dialog.textContent).toContain("Source: /images/relative.jpg");
+ });
});
diff --git a/client/components/Search/Results/Graphical/ImageResultsList.tsx b/client/components/Search/Results/Graphical/ImageResultsList.tsx
index 39f66205..123c1a81 100644
--- a/client/components/Search/Results/Graphical/ImageResultsList.tsx
+++ b/client/components/Search/Results/Graphical/ImageResultsList.tsx
@@ -115,7 +115,7 @@ export default function ImageResultsList({
)}
{sourceUrl && (
- Source: {new URL(sourceUrl).hostname}
+ Source: {getHostname(sourceUrl)}
)}