@@ -58,16 +58,16 @@ export class StandardOpenapiLinkCodec<T extends ClientContext> implements Standa
5858 const inputStructure = fallbackContractConfig ( 'defaultInputStructure' , procedure [ '~orpc' ] . route . inputStructure )
5959
6060 return inputStructure === 'compact'
61- ? this . #encodeCompact( procedure , path , input , options , baseUrl . toString ( ) , headers )
62- : this . #encodeDetailed( procedure , path , input , options , baseUrl . toString ( ) , headers )
61+ ? this . #encodeCompact( procedure , path , input , options , baseUrl , headers )
62+ : this . #encodeDetailed( procedure , path , input , options , baseUrl , headers )
6363 }
6464
6565 #encodeCompact(
6666 procedure : AnyContractProcedure ,
6767 path : readonly string [ ] ,
6868 input : unknown ,
6969 options : ClientOptions < T > ,
70- baseUrl : string ,
70+ baseUrl : string | URL ,
7171 headers : StandardHeaders ,
7272 ) : StandardRequest {
7373 let httpPath = standardizeHTTPPath ( procedure [ '~orpc' ] . route . path ?? toHttpPath ( path ) )
@@ -92,7 +92,8 @@ export class StandardOpenapiLinkCodec<T extends ClientContext> implements Standa
9292 }
9393
9494 const method = fallbackContractConfig ( 'defaultMethod' , procedure [ '~orpc' ] . route . method )
95- const url = new URL ( `${ baseUrl . toString ( ) . replace ( / \/ $ / , '' ) } ${ httpPath } ` )
95+ const url = new URL ( baseUrl )
96+ url . pathname = `${ url . pathname . replace ( / \/ $ / , '' ) } ${ httpPath } `
9697
9798 if ( method === 'GET' ) {
9899 const serialized = this . serializer . serialize ( httpBody , { outputFormat : 'URLSearchParams' } ) as URLSearchParams
@@ -124,7 +125,7 @@ export class StandardOpenapiLinkCodec<T extends ClientContext> implements Standa
124125 path : readonly string [ ] ,
125126 input : unknown ,
126127 options : ClientOptions < T > ,
127- baseUrl : string ,
128+ baseUrl : string | URL ,
128129 headers : StandardHeaders ,
129130 ) : StandardRequest {
130131 let httpPath = standardizeHTTPPath ( procedure [ '~orpc' ] . route . path ?? toHttpPath ( path ) )
@@ -156,7 +157,8 @@ export class StandardOpenapiLinkCodec<T extends ClientContext> implements Standa
156157 }
157158
158159 const method = fallbackContractConfig ( 'defaultMethod' , procedure [ '~orpc' ] . route . method )
159- const url = new URL ( `${ baseUrl . toString ( ) . replace ( / \/ $ / , '' ) } ${ httpPath } ` )
160+ const url = new URL ( baseUrl )
161+ url . pathname = `${ url . pathname . replace ( / \/ $ / , '' ) } ${ httpPath } `
160162
161163 if ( input ?. query !== undefined ) {
162164 const query = this . serializer . serialize ( input . query , { outputFormat : 'URLSearchParams' } ) as URLSearchParams
0 commit comments