github.com/tilt-dev/tilt@v0.33.15-0.20240515162809-0a22ed45d8a0/web/src/links.test.tsx (about) 1 import { resolveURL, displayURL } from "./links" 2 3 describe("links", () => { 4 it("resolves 0.0.0.0", () => { 5 expect(resolveURL("http://localhost:8000/x")).toEqual( 6 "http://localhost:8000/x" 7 ) 8 expect(resolveURL("http://0.0.0.0:8000/x")).toEqual( 9 "http://localhost:8000/x" 10 ) 11 }) 12 13 it("handles partial urls", () => { 14 expect(resolveURL("localhost:8000")).toEqual("localhost:8000") 15 }) 16 17 it("strips schemes", () => { 18 expect(displayURL("https://localhost:8000")).toEqual("localhost:8000") 19 expect(displayURL("http://localhost:8000")).toEqual("localhost:8000") 20 expect(displayURL("http://www.google.com")).toEqual("google.com") 21 }) 22 23 it("strips trailing slash", () => { 24 expect(displayURL("http://localhost:8000/")).toEqual("localhost:8000") 25 expect(displayURL("http://localhost:8000/foo/")).toEqual( 26 "localhost:8000/foo/" 27 ) 28 expect(displayURL("http://localhost/")).toEqual("localhost") 29 expect(displayURL("http://localhost/foo/")).toEqual("localhost/foo/") 30 }) 31 })