GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test(shared): cover advertised endpoint URL normalization and compati… · pingdotgg/t3code@8cfd2b5

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/shared/src
    • advertisedEndpoint.test.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

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

Copy file name to clipboard
+57Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { describe, expect, it } from "vite-plus/test";
2+
3+
import {
4+
createAdvertisedEndpoint,
5+
type CreateAdvertisedEndpointInput,
6+
normalizeHttpBaseUrl,
7+
} from "./advertisedEndpoint.ts";
8+
9+
describe("normalizeHttpBaseUrl", () => {
10+
it("rejects non-http(s) schemes", () => {
11+
expect(() => normalizeHttpBaseUrl("ftp://example.com")).toThrow(/HTTP or HTTPS/);
12+
});
13+
});
14+
15+
describe("createAdvertisedEndpoint", () => {
16+
const input = {
17+
id: "e1",
18+
label: "Local",
19+
provider: { id: "desktop-core", label: "Desktop", kind: "core", isAddon: false },
20+
reachability: "loopback",
21+
source: "desktop-core",
22+
} satisfies Omit<CreateAdvertisedEndpointInput, "httpBaseUrl">;
23+
24+
it("marks plain-http endpoints as mixed-content blocked for hosted apps", () => {
25+
const endpoint = createAdvertisedEndpoint({
26+
...input,
27+
httpBaseUrl: "http://192.168.1.10:8317",
28+
});
29+
expect(endpoint.compatibility.hostedHttpsApp).toBe("mixed-content-blocked");
30+
expect(endpoint.compatibility.desktopApp).toBe("compatible");
31+
expect(endpoint.wsBaseUrl).toBe("ws://192.168.1.10:8317/");
32+
});
33+
34+
it("leaves https endpoints as unknown by default", () => {
35+
expect(
36+
createAdvertisedEndpoint({ ...input, httpBaseUrl: "https://example.com" }).compatibility
37+
.hostedHttpsApp,
38+
).toBe("unknown");
39+
});
40+
41+
it("uses an explicit hosted-https compatibility flag as given", () => {
42+
expect(
43+
createAdvertisedEndpoint({
44+
...input,
45+
httpBaseUrl: "https://example.com",
46+
hostedHttpsCompatibility: "compatible",
47+
}).compatibility.hostedHttpsApp,
48+
).toBe("compatible");
49+
expect(
50+
createAdvertisedEndpoint({
51+
...input,
52+
httpBaseUrl: "https://example.com",
53+
hostedHttpsCompatibility: "mixed-content-blocked",
54+
}).compatibility.hostedHttpsApp,
55+
).toBe("mixed-content-blocked");
56+
});
57+
});

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.