Skip to content

Commit 73c0214

Browse files
committed
address base path review comments
1 parent a29e812 commit 73c0214

3 files changed

Lines changed: 24 additions & 9 deletions

File tree

apps/web/src/components/SplashScreen.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1+
import { BASE_PATH } from "../basePath";
2+
13
export function SplashScreen() {
24
return (
35
<div className="flex min-h-screen items-center justify-center bg-background">
46
<div className="flex size-24 items-center justify-center" aria-label="T3 Code splash screen">
5-
<img alt="T3 Code" className="size-16 object-contain" src="./apple-touch-icon.png" />
7+
<img
8+
alt="T3 Code"
9+
className="size-16 object-contain"
10+
src={`${BASE_PATH}/apple-touch-icon.png`}
11+
/>
612
</div>
713
</div>
814
);

packages/client-runtime/src/advertisedEndpoint.test.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { describe, expect, it } from "vitest";
22

3+
import { NormalizedBasePath } from "@t3tools/shared/basePath";
34
import {
45
classifyHostedHttpsCompatibility,
56
createAdvertisedEndpoint,
@@ -16,14 +17,23 @@ const coreProvider = {
1617

1718
describe("advertised endpoint helpers", () => {
1819
it("normalizes HTTP and WebSocket base URLs", () => {
19-
expect(normalizeHttpBaseUrl("https://example.com/path?x=1#hash")).toBe(
20-
"https://example.com/path/",
21-
);
22-
expect(normalizeHttpBaseUrl("wss://example.com/socket")).toBe("https://example.com/socket/");
23-
expect(deriveWsBaseUrl("https://example.com/api")).toBe("wss://example.com/api/");
20+
expect(normalizeHttpBaseUrl("https://example.com/path?x=1#hash")).toBe("https://example.com/");
21+
expect(normalizeHttpBaseUrl("wss://example.com/socket")).toBe("https://example.com/");
22+
expect(deriveWsBaseUrl("https://example.com/api")).toBe("wss://example.com/");
2423
expect(deriveWsBaseUrl("http://127.0.0.1:3773")).toBe("ws://127.0.0.1:3773/");
2524
});
2625

26+
it("uses explicit base path when provided", () => {
27+
const basePath = NormalizedBasePath("/custom");
28+
29+
expect(normalizeHttpBaseUrl("https://example.com/path?x=1#hash", { basePath })).toBe(
30+
"https://example.com/custom/",
31+
);
32+
expect(deriveWsBaseUrl("https://example.com/api", { basePath })).toBe(
33+
"wss://example.com/custom/",
34+
);
35+
});
36+
2737
it("marks HTTP endpoints as blocked from hosted HTTPS apps", () => {
2838
expect(classifyHostedHttpsCompatibility("http://192.168.1.44:3773")).toBe(
2939
"mixed-content-blocked",

packages/shared/src/advertisedEndpoint.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ import type {
66
AdvertisedEndpointSource,
77
AdvertisedEndpointStatus,
88
} from "@t3tools/contracts";
9-
import * as Effect from "effect/Effect";
109

11-
import { normalizeBasePath, type NormalizedBasePath } from "./basePath.ts";
10+
import { ROOT_BASE_PATH, type NormalizedBasePath } from "./basePath.ts";
1211

1312
export interface CreateAdvertisedEndpointInput {
1413
readonly id: string;
@@ -42,7 +41,7 @@ export function normalizeHttpBaseUrl(
4241
if (url.protocol !== "http:" && url.protocol !== "https:") {
4342
throw new Error(`Endpoint must use HTTP or HTTPS. Received ${url.protocol}`);
4443
}
45-
url.pathname = `${options?.basePath ?? Effect.runSync(normalizeBasePath(url.pathname))}/`;
44+
url.pathname = `${options?.basePath ?? ROOT_BASE_PATH}/`;
4645
url.search = "";
4746
url.hash = "";
4847
return url.toString();

0 commit comments

Comments
 (0)