Skip to content

Commit

Permalink
Merge pull request #2896 from bcameron1231/fix-2895
Browse files Browse the repository at this point in the history
2895 - Rootweb fix
  • Loading branch information
juliemturner authored Jan 12, 2024
2 parents 711db53 + 1a3ed9a commit 2cacb70
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/sp/webs/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function rebaseWebUrl(candidate: string, path: string | undefined): string {
// - test if `candidate` already has an api path
// - ensure that we append the correct one as sometimes a web is not defined
// by _api/web, in the case of _api/site/rootweb for example
const matches = /(_api[/|\\](site|web))/i.exec(candidate);
const matches = /(_api[/|\\](site\/rootweb|site|web))/i.exec(candidate);
if (matches?.length > 0) {
// we want just the base url part (before the _api)
candidate = extractWebUrl(candidate);
Expand Down
8 changes: 7 additions & 1 deletion test/sp/sites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import "@pnp/sp/sites";
import "@pnp/sp/webs";
import "@pnp/sp/lists/web";
import { IDocumentLibraryInformation, IOpenWebByIdResult, ISiteLogoProperties, Site, SiteLogoAspect, SiteLogoType } from "@pnp/sp/sites";
import "@pnp/sp/site-users";
import { IWebEnsureUserResult } from "@pnp/sp/site-users";
import { IWeb } from "@pnp/sp/webs";
import { combine, getRandomString, stringIsNullOrEmpty } from "@pnp/core";
import { IContextInfo } from "@pnp/sp/context-info";
import "@pnp/sp/context-info";


import "@pnp/sp/files";
import { IFiles } from "@pnp/sp/files";
import { readFileSync } from "fs";
Expand Down Expand Up @@ -36,6 +37,11 @@ describe("Sites", function () {
return expect(rootWeb).to.haveOwnProperty("_url");
});

it("rootWeb - ensureUser", async function () {
const user: IWebEnsureUserResult = await this.pnp.sp.site.rootWeb.ensureUser(this.pnp.settings.testUser);
return expect(user.data).to.haveOwnProperty("id");
});

it("getContextInfo", async function () {
const oContext: IContextInfo = await this.pnp.sp.site.getContextInfo();
return expect(oContext).to.haveOwnProperty("SiteFullUrl");
Expand Down

0 comments on commit 2cacb70

Please sign in to comment.