44 type PreviewUrlResolution ,
55} from "@t3tools/contracts" ;
66import { isLoopbackHost , normalizePreviewUrl } from "@t3tools/shared/preview" ;
7+ import { getUrlDiagnostics } from "@t3tools/shared/urlDiagnostics" ;
78import * as Schema from "effect/Schema" ;
89
910import { readPreparedConnection } from "~/state/session" ;
@@ -23,12 +24,14 @@ export class BrowserTargetEnvironmentUrlInvalidError extends Schema.TaggedErrorC
2324 "BrowserTargetEnvironmentUrlInvalidError" ,
2425 {
2526 environmentId : EnvironmentId ,
26- httpBaseUrl : Schema . String ,
27+ httpBaseUrlInputLength : Schema . Number ,
28+ httpBaseUrlProtocol : Schema . optionalKey ( Schema . String ) ,
29+ httpBaseUrlHostname : Schema . optionalKey ( Schema . String ) ,
2730 cause : Schema . Defect ( ) ,
2831 } ,
2932) {
3033 override get message ( ) : string {
31- return `Environment ${ this . environmentId } has an invalid HTTP base URL: ${ this . httpBaseUrl } .` ;
34+ return `Environment ${ this . environmentId } has an invalid HTTP base URL input of length ${ this . httpBaseUrlInputLength } .` ;
3235 }
3336}
3437
@@ -81,9 +84,12 @@ export function resolveBrowserNavigationTarget(
8184 try {
8285 environmentUrl = new URL ( connection . httpBaseUrl ) ;
8386 } catch ( cause ) {
87+ const diagnostics = getUrlDiagnostics ( connection . httpBaseUrl ) ;
8488 throw new BrowserTargetEnvironmentUrlInvalidError ( {
8589 environmentId,
86- httpBaseUrl : connection . httpBaseUrl ,
90+ httpBaseUrlInputLength : diagnostics . inputLength ,
91+ ...( diagnostics . protocol === undefined ? { } : { httpBaseUrlProtocol : diagnostics . protocol } ) ,
92+ ...( diagnostics . hostname === undefined ? { } : { httpBaseUrlHostname : diagnostics . hostname } ) ,
8793 cause,
8894 } ) ;
8995 }
0 commit comments