@@ -52,9 +52,7 @@ export class RocDocument<
5252 responseType : 'text' | 'arraybuffer' | 'blob' ,
5353 axiosOptions ?: RocAxiosRequestOptions ,
5454 ) : Promise < Buffer | string > {
55- const url = new URL ( name , this . getBaseUrl ( ) ) . href ;
56- const response = await this . request ( {
57- url,
55+ const response = await this . request . get ( name , {
5856 responseType,
5957 ...axiosOptions ,
6058 } ) ;
@@ -68,7 +66,7 @@ export class RocDocument<
6866 if ( rev ) {
6967 throw new Error ( 'UNIMPLEMENTED fetch with rev' ) ;
7068 }
71- const response = await this . request . get ( '/ ' , axiosOptions ) ;
69+ const response = await this . request . get ( '' , axiosOptions ) ;
7270 this . value = response . data ;
7371 return response . data ;
7472 }
@@ -111,7 +109,7 @@ export class RocDocument<
111109 }
112110
113111 // Send the new doc
114- await this . request . put ( '/ ' , newDoc , axiosOptions ) ;
112+ await this . request . put ( '' , newDoc , axiosOptions ) ;
115113
116114 // Get the new document
117115 // With updated properties ($lastModifification...)
@@ -139,14 +137,15 @@ export class RocDocument<
139137 }
140138
141139 public async delete ( axiosOptions ?: RocAxiosRequestOptions ) {
142- const response = await this . request . delete ( '/ ' , axiosOptions ) ;
140+ const response = await this . request . delete ( '' , axiosOptions ) ;
143141 if ( response . data . ok ) {
144142 this . value = undefined ;
145143 this . deleted = true ;
146144 } else {
147145 throw new Error ( 'document was not deleted' ) ;
148146 }
149147 }
148+
150149 public getAttachment ( name : string ) : RocAttachment {
151150 if ( this . value === undefined ) {
152151 throw new RocClientError (
@@ -161,7 +160,7 @@ export class RocDocument<
161160 return {
162161 ...attachments [ name ] ,
163162 name,
164- url : ` ${ this . getBaseUrl ( ) } ${ name } ` ,
163+ url : this . request . getUri ( { url : name } ) ,
165164 } ;
166165 }
167166
@@ -182,9 +181,6 @@ export class RocDocument<
182181 return response . data ;
183182 }
184183
185- protected getBaseUrl ( ) {
186- return this . request . defaults . baseURL || '' ;
187- }
188184 private async _fetchIfUnfetched ( ) {
189185 if ( this . value === undefined ) {
190186 await this . fetch ( ) ;
0 commit comments