(config: OpenAPIConfig, options: ApiRequestOptions)
| 82 | }; |
| 83 | |
| 84 | const getUrl = (config: OpenAPIConfig, options: ApiRequestOptions): string => { |
| 85 | const encoder = config.ENCODE_PATH || encodeURI; |
| 86 | |
| 87 | const path = options.url |
| 88 | .replace('{api-version}', config.VERSION) |
| 89 | .replace(/{(.*?)}/g, (substring: string, group: string) => { |
| 90 | if (options.path?.hasOwnProperty(group)) { |
| 91 | return encoder(String(options.path[group])); |
| 92 | } |
| 93 | return substring; |
| 94 | }); |
| 95 | |
| 96 | const url = `${config.BASE}${path}`; |
| 97 | if (options.query) { |
| 98 | return `${url}${getQueryString(options.query)}`; |
| 99 | } |
| 100 | return url; |
| 101 | }; |
| 102 | |
| 103 | export const getFormData = (options: ApiRequestOptions): FormData | undefined => { |
| 104 | if (options.formData) { |
no test coverage detected