Skip to content

Commit 7379bbc

Browse files
committed
Allow http and https preview URLs
- accept remote http/https preview URLs in desktop validation - update preview copy and tests for the new URL rules - keep theme switcher formatting consistent
1 parent fb6075d commit 7379bbc

3 files changed

Lines changed: 20 additions & 21 deletions

File tree

apps/desktop/src/preview.test.ts

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,22 @@ describe("validateDesktopPreviewUrl", () => {
1919
});
2020
});
2121

22-
it("rejects missing, malformed, or remote URLs", () => {
22+
it("accepts https and remote http URLs", () => {
23+
expect(validateDesktopPreviewUrl("https://localhost:3000")).toEqual({
24+
ok: true,
25+
url: "https://localhost:3000/",
26+
});
27+
expect(validateDesktopPreviewUrl("http://example.com:3000")).toEqual({
28+
ok: true,
29+
url: "http://example.com:3000/",
30+
});
31+
expect(validateDesktopPreviewUrl("http://localhost")).toEqual({
32+
ok: true,
33+
url: "http://localhost/",
34+
});
35+
});
36+
37+
it("rejects missing, malformed, or non-http URLs", () => {
2338
expect(validateDesktopPreviewUrl("")).toEqual({
2439
ok: false,
2540
error: {
@@ -34,25 +49,11 @@ describe("validateDesktopPreviewUrl", () => {
3449
message: "Preview URL is not a valid URL.",
3550
},
3651
});
37-
expect(validateDesktopPreviewUrl("https://localhost:3000")).toEqual({
38-
ok: false,
39-
error: {
40-
code: "non-local-url",
41-
message: "Preview only supports local http URLs.",
42-
},
43-
});
44-
expect(validateDesktopPreviewUrl("http://example.com:3000")).toEqual({
45-
ok: false,
46-
error: {
47-
code: "non-local-url",
48-
message: "Preview only supports localhost, 127.0.0.1, or ::1.",
49-
},
50-
});
51-
expect(validateDesktopPreviewUrl("http://localhost")).toEqual({
52+
expect(validateDesktopPreviewUrl("ftp://localhost:3000")).toEqual({
5253
ok: false,
5354
error: {
5455
code: "invalid-url",
55-
message: "Preview URL must include an explicit port.",
56+
message: "Preview only supports http and https URLs.",
5657
},
5758
});
5859
});

apps/web/src/components/PreviewPanel.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe("resolvePreviewStatusCopy", () => {
1212
visible: false,
1313
error: null,
1414
}),
15-
).toContain("localhost URL");
15+
).toContain("Enter a URL");
1616

1717
expect(
1818
resolvePreviewStatusCopy({

apps/web/src/components/ThemeModeSwitcher.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ export function ThemeModeSwitcher() {
2424
aria-label={label}
2525
className={cn(
2626
"flex h-6 flex-1 items-center justify-center rounded-md text-muted-foreground transition-colors",
27-
isActive
28-
? "bg-background text-foreground shadow-xs"
29-
: "hover:text-foreground/80",
27+
isActive ? "bg-background text-foreground shadow-xs" : "hover:text-foreground/80",
3028
)}
3129
onClick={() => setTheme(value)}
3230
>

0 commit comments

Comments
 (0)