Skip to content

Commit

Permalink
SharePoint API: service root url fix for web resource
Browse files Browse the repository at this point in the history
  • Loading branch information
vgrem committed Jul 15, 2023
1 parent 4cf1296 commit a21177f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/SharePoint/Web.php
Original file line number Diff line number Diff line change
Expand Up @@ -2138,7 +2138,10 @@ public function getResourceUrl()
{
$url = parent::getResourceUrl();
if (!is_null($this->webUrl)) {
return str_replace("/_api", "{$this->webUrl}/_api", $url);
$urlInfo = parse_url($this->getContext()->getBaseUrl());
$rootSiteUrl = $urlInfo['scheme'] . '://' . $urlInfo['host'];
return "{$rootSiteUrl}{$this->webUrl}/_api/web";
#return str_replace("/_api", "{$this->webUrl}/_api", $url);
}
return $url;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/sharepoint/WebTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ public function testAssignUniquePermissions(Web $targetWeb)
->breakRoleInheritance(true)
->executeQuery();

$targetWeb->select("HasUniqueRoleAssignments")->get()->executeQuery();
self::assertTrue($targetWeb->getHasUniqueRoleAssignments());
$result = $targetWeb->select(["HasUniqueRoleAssignments"])->get()->executeQuery();
self::assertTrue($result->getHasUniqueRoleAssignments());
}

/**
Expand Down

0 comments on commit a21177f

Please sign in to comment.