11import { describe , expect , it } from "vitest" ;
22
3+ import { NormalizedBasePath } from "@t3tools/shared/basePath" ;
34import {
45 classifyHostedHttpsCompatibility ,
56 createAdvertisedEndpoint ,
@@ -16,14 +17,23 @@ const coreProvider = {
1617
1718describe ( "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" ,
0 commit comments