Skip to content

Commit

Permalink
Defaulted the web url for the v2 execution. It will not work against …
Browse files Browse the repository at this point in the history
…sub folders like v1.
  • Loading branch information
gunjandatta committed Dec 13, 2024
1 parent 5947218 commit 9a55a88
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion dist/gd-sprest.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/gd-sprest.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gd-sprest",
"version": "8.6.3",
"version": "8.6.4",
"description": "An easy way to develop against the SharePoint REST API.",
"author": "Gunjan Datta <[email protected]> (https://gunjandatta.github.io)",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion src/rest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { IREST } from "../@types";
* SharePoint REST Library
*/
export const $REST: IREST = {
__ver: 8.63,
__ver: 8.64,
AppContext: (siteUrl: string) => { return Lib.Site.getAppContext(siteUrl); },
Apps: Lib.Apps,
ContextInfo: Lib.ContextInfo,
Expand Down
8 changes: 3 additions & 5 deletions src/v2/drive.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Idrive } from "../../@types/v2";
import { ITargetInfoProps } from "../../@types/utils";
import { ContextInfo } from "../lib/contextInfo";
import { Base, Request, RequestType } from "../utils";
import { init } from "./common";

Expand All @@ -17,11 +18,8 @@ export const drive: Idrive = ((props: { siteId?: string, siteUrl?: string, targe
drive.targetInfo.defaultToWebFl = true;
drive.targetInfo.requestType = RequestType.GraphGet;

// See if the web url exists
if (props.siteUrl) {
// Set the settings
drive.targetInfo.url = props.siteUrl;
}
// Default the url
drive.targetInfo.url = props.siteUrl || props?.targetInfo?.url || ContextInfo.webServerRelativeUrl;

// See if an endpoint is not defined
if (drive.targetInfo.endpoint == undefined) {
Expand Down
8 changes: 3 additions & 5 deletions src/v2/drives.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ITargetInfoProps } from "../../@types/utils";
import { Idrives } from "../../@types/v2";
import { ContextInfo } from "../lib/contextInfo";
import { Base, Request, RequestType } from "../utils";
import { init } from "./common";

Expand All @@ -17,11 +18,8 @@ export const drives: Idrives = ((props: { driveId?: string, siteId?: string, sit
drives.targetInfo.defaultToWebFl = true;
drives.targetInfo.requestType = RequestType.GraphGet;

// See if the web url exists
if (props.siteUrl) {
// Set the settings
drives.targetInfo.url = props.siteUrl;
}
// Default the url
drives.targetInfo.url = props.siteUrl || props?.targetInfo?.url || ContextInfo.webServerRelativeUrl;

// See if an endpoint is not defined
if (drives.targetInfo.endpoint == undefined) {
Expand Down
9 changes: 6 additions & 3 deletions src/v2/sites.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ITargetInfoProps } from "../../@types/utils";
import { ITargetInfoProps, TargetInfo } from "../../@types/utils";
import { Isites } from "../../@types/v2";
import { ContextInfo } from "../lib/contextInfo";
import { Site } from "../lib/site";
Expand All @@ -21,15 +21,18 @@ export const sites: Isites = ((props: { siteId?: string, webId?: string, targetI
sites.targetInfo.endpoint = "_api/v2.0/sites" + (props.siteId ? "/" + props.siteId : "");
sites.targetInfo.requestType = RequestType.GraphGet;

// Default the url
sites.targetInfo.url = props?.targetInfo?.url || ContextInfo.webServerRelativeUrl;

// See if the site id was provided
if (props.siteId) {
// Append the site id
sites.targetInfo.endpoint += "/" + props.siteId;
sites.targetInfo.endpoint += "/" + props.siteId.replace(/^\{|\}$/g, '');

// See if the web id is provided
if (props.webId) {
// Append the web id
sites.targetInfo.endpoint += "," + props.webId;
sites.targetInfo.endpoint += "," + props.webId.replace(/^\{|\}$/g, '');
}
}

Expand Down

0 comments on commit 9a55a88

Please sign in to comment.