1 | import { combine, isUrlAbsolute } from "@pnp/core";
|
2 | import { BrowserFetchWithRetry, DefaultParse } from "@pnp/queryable";
|
3 | import { DefaultHeaders, DefaultInit } from "./defaults.js";
|
4 | import { RequestDigest } from "./request-digest.js";
|
5 | export function SPBrowser(props) {
|
6 | if ((props === null || props === void 0 ? void 0 : props.baseUrl) && !isUrlAbsolute(props.baseUrl)) {
|
7 | throw Error("SPBrowser props.baseUrl must be absolute when supplied.");
|
8 | }
|
9 | return (instance) => {
|
10 | instance.using(DefaultHeaders(), DefaultInit(), BrowserFetchWithRetry(), DefaultParse(), RequestDigest());
|
11 | if (isUrlAbsolute(props === null || props === void 0 ? void 0 : props.baseUrl)) {
|
12 |
|
13 | instance.on.pre.prepend(async (url, init, result) => {
|
14 | if (!isUrlAbsolute(url)) {
|
15 | url = combine(props.baseUrl, url);
|
16 | }
|
17 | return [url, init, result];
|
18 | });
|
19 | }
|
20 | return instance;
|
21 | };
|
22 | }
|
23 |
|
\ | No newline at end of file |