( api: Api, defaultMethod: string = 'get' )
| 85 | const isIE = !!(document as any).documentMode; |
| 86 | |
| 87 | export function normalizeApi( |
| 88 | api: Api, |
| 89 | defaultMethod: string = 'get' |
| 90 | ): ApiObject { |
| 91 | if (typeof api === 'string') { |
| 92 | let method = rSchema.test(api) ? RegExp.$1 : ''; |
| 93 | method && (api = api.replace(method + ':', '')); |
| 94 | |
| 95 | api = { |
| 96 | method: (method || defaultMethod) as any, |
| 97 | url: api |
| 98 | }; |
| 99 | } else { |
| 100 | api = { |
| 101 | ...api |
| 102 | }; |
| 103 | } |
| 104 | api.url = typeof api.url === 'string' ? api.url.trim() : api.url; |
| 105 | return api; |
| 106 | } |
| 107 | |
| 108 | export function buildApi( |
| 109 | api: Api, |
no test coverage detected