File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -473,22 +473,32 @@ function normalizeBaseUrl(baseURL: string) {
473473 throw new Error ( "baseURL must be a valid absolute URL" ) ;
474474 }
475475
476+ assertValidBaseUrlProtocol ( parsedBaseUrl ) ;
477+ assertBaseUrlHasNoQueryOrHash ( parsedBaseUrl ) ;
478+ assertBaseUrlHasNoCredentials ( parsedBaseUrl ) ;
479+
480+ return normalizedBaseUrl ;
481+ }
482+
483+ function assertValidBaseUrlProtocol ( parsedBaseUrl : URL ) {
476484 if (
477485 parsedBaseUrl . protocol !== "http:" &&
478486 parsedBaseUrl . protocol !== "https:"
479487 ) {
480488 throw new Error ( "baseURL must use http or https protocol" ) ;
481489 }
490+ }
482491
492+ function assertBaseUrlHasNoQueryOrHash ( parsedBaseUrl : URL ) {
483493 if ( parsedBaseUrl . search . length > 0 || parsedBaseUrl . hash . length > 0 ) {
484494 throw new Error ( "baseURL must not include query parameters or hash fragments" ) ;
485495 }
496+ }
486497
498+ function assertBaseUrlHasNoCredentials ( parsedBaseUrl : URL ) {
487499 if ( parsedBaseUrl . username . length > 0 || parsedBaseUrl . password . length > 0 ) {
488500 throw new Error ( "baseURL must not include username or password credentials" ) ;
489501 }
490-
491- return normalizedBaseUrl ;
492502}
493503
494504function createTransportRequest < UI_MESSAGE extends UIMessage > (
You can’t perform that action at this time.
0 commit comments