main
Last change
on this file since d24f17c was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
Rev | Line | |
---|
[d24f17c] | 1 | import Http from '../../http/index.js';
|
---|
| 2 | export const retrievalURI = options => {
|
---|
| 3 | var _ref, _globalThis$document;
|
---|
| 4 | /**
|
---|
| 5 | * Swagger-UI uses baseDoc instead of url, this helper function exists
|
---|
| 6 | * to allow both.
|
---|
| 7 | *
|
---|
| 8 | * In browser environment, we allow to pass a relative URI Reference,
|
---|
| 9 | * and we resolve it against the document's baseURI before passing it deeper
|
---|
| 10 | * to swagger-client code.
|
---|
| 11 | */
|
---|
| 12 | const {
|
---|
| 13 | baseDoc,
|
---|
| 14 | url
|
---|
| 15 | } = options;
|
---|
| 16 | const retrievalURL = (_ref = baseDoc !== null && baseDoc !== void 0 ? baseDoc : url) !== null && _ref !== void 0 ? _ref : '';
|
---|
| 17 | return typeof ((_globalThis$document = globalThis.document) === null || _globalThis$document === void 0 ? void 0 : _globalThis$document.baseURI) === 'string' ? String(new URL(retrievalURL, globalThis.document.baseURI)) : retrievalURL;
|
---|
| 18 | };
|
---|
| 19 | export const httpClient = options => {
|
---|
| 20 | const {
|
---|
| 21 | fetch,
|
---|
| 22 | http
|
---|
| 23 | } = options;
|
---|
| 24 |
|
---|
| 25 | // @TODO fetch should be removed, and http used instead
|
---|
| 26 | // provide a default fetch implementation
|
---|
| 27 | return fetch || http || Http;
|
---|
| 28 | }; |
---|
Note:
See
TracBrowser
for help on using the repository browser.