Skip to content

Commit 0ef7295

Browse files
refactor(shared): remove unused preview URL predicate
1 parent d2c3e2e commit 0ef7295

2 files changed

Lines changed: 0 additions & 30 deletions

File tree

‎packages/shared/src/preview.test.ts‎

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { describe, expect, it } from "vite-plus/test";
22

33
import {
44
isLoopbackHost,
5-
isPreviewableUrl,
65
newPreviewTabId,
76
normalizePreviewUrl,
87
PreviewUrlNormalizationError,
@@ -27,24 +26,6 @@ describe("isLoopbackHost", () => {
2726
});
2827
});
2928

30-
describe("isPreviewableUrl", () => {
31-
it.each([
32-
"http://localhost:5173",
33-
"http://127.0.0.1:3000/path",
34-
"http://0.0.0.0:8080",
35-
"http://[::1]:5173",
36-
])("%s is previewable", (url) => {
37-
expect(isPreviewableUrl(url)).toBe(true);
38-
});
39-
40-
it.each(["https://example.com", "ws://localhost:5173", "file:///etc/passwd", "not-a-url", ""])(
41-
"%s is not previewable",
42-
(url) => {
43-
expect(isPreviewableUrl(url)).toBe(false);
44-
},
45-
);
46-
});
47-
4829
describe("normalizePreviewUrl", () => {
4930
it("treats bare loopback hosts as http", () => {
5031
expect(normalizePreviewUrl("localhost:5173")).toBe("http://localhost:5173/");

‎packages/shared/src/preview.ts‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,6 @@ export function isLoopbackHost(host: string): boolean {
3636
return false;
3737
}
3838

39-
/** True when a raw URL string looks like a loopback dev URL we can preview. */
40-
export function isPreviewableUrl(rawUrl: string): boolean {
41-
try {
42-
const parsed = new URL(rawUrl);
43-
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") return false;
44-
return isLoopbackHost(parsed.hostname);
45-
} catch {
46-
return false;
47-
}
48-
}
49-
5039
export class PreviewUrlNormalizationError extends Schema.TaggedErrorClass<PreviewUrlNormalizationError>()(
5140
"PreviewUrlNormalizationError",
5241
{

0 commit comments

Comments
 (0)