Spaces:
Paused
Paused
Download src/lib/server/isURLLocal.spec.ts from vollsteksolutions/test: direct link, hf CLI and curl.
- Browser
- Download file 1.23 kB
-
https://huggingface.co/spaces/vollsteksolutions/test/resolve/main/src/lib/server/isURLLocal.spec.ts
- Command line
-
hf download hf://spaces/vollsteksolutions/test/src/lib/server/isURLLocal.spec.ts
-
curl -L -o isURLLocal.spec.ts https://huggingface.co/spaces/vollsteksolutions/test/resolve/main/src/lib/server/isURLLocal.spec.ts
1.23 kB
| import { isURLLocal } from "./isURLLocal"; | |
| import { describe, expect, it } from "vitest"; | |
| describe("isURLLocal", async () => { | |
| it("should return true for localhost", async () => { | |
| expect(await isURLLocal(new URL("http://localhost"))).toBe(true); | |
| }); | |
| it("should return true for 127.0.0.1", async () => { | |
| expect(await isURLLocal(new URL("http://127.0.0.1"))).toBe(true); | |
| }); | |
| it("should return true for 127.254.254.254", async () => { | |
| expect(await isURLLocal(new URL("http://127.254.254.254"))).toBe(true); | |
| }); | |
| it("should return false for huggingface.co", async () => { | |
| expect(await isURLLocal(new URL("https://huggingface.co/"))).toBe(false); | |
| }); | |
| it("should return true for 127.0.0.1.nip.io", async () => { | |
| expect(await isURLLocal(new URL("http://127.0.0.1.nip.io"))).toBe(true); | |
| }); | |
| it("should fail on ipv6", async () => { | |
| await expect(isURLLocal(new URL("http://[::1]"))).rejects.toThrow(); | |
| }); | |
| it("should fail on ipv6 --1.sslip.io", async () => { | |
| await expect(isURLLocal(new URL("http://--1.sslip.io"))).rejects.toThrow(); | |
| }); | |
| it("should fail on invalid domain names", async () => { | |
| await expect( | |
| isURLLocal(new URL("http://34329487239847329874923948732984.com/")) | |
| ).rejects.toThrow(); | |
| }); | |
| }); | |