22 isEmptyArray ,
33 isFunction ,
44 isPlainObject ,
5- isString ,
65 isUndefined ,
76} from './helpers/isTypes' ;
87import { assert , throwError } from './helpers/error' ;
@@ -152,7 +151,7 @@ export function getAdapterDefault(): AxiosAdapter | undefined {
152151 try {
153152 const tryGetPlatform = tryGetPlatforms . shift ( ) ;
154153
155- if ( isPlainObject ( ( platform = tryGetPlatform ?. ( ) ) ) ) {
154+ if ( isPlainObject ( ( platform = tryGetPlatform ! ( ) ) ) ) {
156155 platform = revisePlatformApiNames ( platform ) ;
157156 }
158157 } catch ( err ) {
@@ -169,13 +168,11 @@ export function getAdapterDefault(): AxiosAdapter | undefined {
169168
170169export function createAdapter ( platform : AxiosPlatform ) : AxiosAdapter {
171170 assert ( isPlainObject ( platform ) , 'platform 不是一个 object' ) ;
172- assert ( isFunction ( platform . request ) , 'platform. request 不是一个 function' ) ;
173- assert ( isFunction ( platform . upload ) , 'platform. upload 不是一个 function' ) ;
174- assert ( isFunction ( platform . download ) , 'platform. download 不是一个 function' ) ;
171+ assert ( isFunction ( platform . request ) , 'request 不是一个 function' ) ;
172+ assert ( isFunction ( platform . upload ) , 'upload 不是一个 function' ) ;
173+ assert ( isFunction ( platform . download ) , 'download 不是一个 function' ) ;
175174
176- function adapterDefault (
177- config : AxiosAdapterRequestConfig ,
178- ) : AxiosAdapterTask | void {
175+ function adapter ( config : AxiosAdapterRequestConfig ) : AxiosAdapterTask | void {
179176 const baseOptions = transformOptions ( config ) ;
180177
181178 switch ( config . type ) {
@@ -201,16 +198,6 @@ export function createAdapter(platform: AxiosPlatform): AxiosAdapter {
201198 upload : AxiosAdapterUpload ,
202199 baseOptions : AxiosAdapterBaseOptions ,
203200 ) : AxiosAdapterTask | void {
204- assert ( isPlainObject ( baseOptions . data ) , 'data 不是一个 object' ) ;
205- assert (
206- isString ( baseOptions . data ?. fileName ) ,
207- 'data.fileName 不是一个 string' ,
208- ) ;
209- assert (
210- isString ( baseOptions . data ?. filePath ) ,
211- 'data.filePath 不是一个 string' ,
212- ) ;
213-
214201 const { fileName, filePath, fileType, ...formData } =
215202 baseOptions . data as AxiosRequestFormData ;
216203 const options = {
@@ -306,7 +293,7 @@ export function createAdapter(platform: AxiosPlatform): AxiosAdapter {
306293 }
307294 }
308295
309- return adapterDefault ;
296+ return adapter ;
310297}
311298
312299export function isPlatform ( value : unknown ) : value is AxiosPlatform {
0 commit comments