(baseUrl: string | undefined, pathOrUrl: string)
| 5 | import { performRequest } from './NativeHTTPClient'; |
| 6 | |
| 7 | function makeURL(baseUrl: string | undefined, pathOrUrl: string): string { |
| 8 | if (pathOrUrl.indexOf('://') >= 0) { |
| 9 | return pathOrUrl; |
| 10 | } |
| 11 | if (!baseUrl) { |
| 12 | throw new Error('baseUrl should be specified when providing a relative path'); |
| 13 | } |
| 14 | |
| 15 | if (!baseUrl.endsWith('/')) { |
| 16 | baseUrl += '/'; |
| 17 | } |
| 18 | if (pathOrUrl.startsWith('/')) { |
| 19 | pathOrUrl = pathOrUrl.substring(1); |
| 20 | } |
| 21 | return baseUrl + pathOrUrl; |
| 22 | } |
| 23 | |
| 24 | export class HTTPClient implements IHTTPClient { |
| 25 | constructor(readonly baseUrl?: string | undefined) {} |
no test coverage detected