refactor(shared): remove unused preview URL predicate (#9989)

This commit is contained in:
Julius Marminge authored and GitHub committed 2026-09-05 00:18:47 -07:00
1 parent 94d1fa7ff2
commit aca2afc0b5
2 files changed
-30

No files matched your search

-19
View File
@@ -2,7 +2,6 @@ import { describe, expect, it } from "vite-plus/test";
import {
isLoopbackHost,
isPreviewableUrl,
newPreviewTabId,
normalizePreviewUrl,
PreviewUrlNormalizationError,
@@ -27,24 +26,6 @@ describe("isLoopbackHost", () => {
});
});
describe("isPreviewableUrl", () => {
it.each([
"http://localhost:5173",
"http://127.0.0.1:3000/path",
"http://0.0.0.0:8080",
"http://[::1]:5173",
])("%s is previewable", (url) => {
expect(isPreviewableUrl(url)).toBe(true);
});
it.each(["https://example.com", "ws://localhost:5173", "file:///etc/passwd", "not-a-url", ""])(
"%s is not previewable",
(url) => {
expect(isPreviewableUrl(url)).toBe(false);
},
);
});
describe("normalizePreviewUrl", () => {
it("treats bare loopback hosts as http", () => {
expect(normalizePreviewUrl("localhost:5173")).toBe("http://localhost:5173/");
-11
View File
@@ -36,17 +36,6 @@ export function isLoopbackHost(host: string): boolean {
return false;
}
/** True when a raw URL string looks like a loopback dev URL we can preview. */
export function isPreviewableUrl(rawUrl: string): boolean {
try {
const parsed = new URL(rawUrl);
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") return false;
return isLoopbackHost(parsed.hostname);
} catch {
return false;
}
}
export class PreviewUrlNormalizationError extends Schema.TaggedErrorClass<PreviewUrlNormalizationError>()(
"PreviewUrlNormalizationError",
{