command spo folder roleinheritance break and reset does not work with rootfolder or site relative of folder
See original GitHub issueDescription
Command spo folder roleinheritance break and spo folder roleinheritance reset throw an error when root folder of a library or preceding slash is present in the folderUrl parameter.
Aim :
-
Add flexibility to pass preceding slash in the parameter value folderUrl without any errors e.g. m365 spo folder roleinheritance reset --webUrl “https://contoso.sharepoint.com/sites/Test_Site” --folderUrl “/Shared Documents/FolderPermission”
-
Allow the root folder url of a library to be passed as parameter value folderUrl e.g. m365 spo folder roleinheritance break --webUrl “https://contoso.sharepoint.com/sites/Test_Site” --folderUrl “/Shared Documents”
Implementation:
- To implement aim 1 , use
const serverRelativeUrl: string = urlUtil.getServerRelativePath(args.options.webUrl, args.options.folderUrl);
to handle different ways the folderUrl value can be passed, i.e.
- with preceding slash
- no preceding slash
- server relative url
- To implement aim 2 to allow root folder to be used , a condition can be added to check whether folderUrl value passed is a root folder and use the appropriate api call
const roleFolderUrl: string = urlUtil.getWebRelativePath(args.options.webUrl, args.options.folderUrl); let requestUrl: string =
${args.options.webUrl}/_api/web/`;
if (roleFolderUrl.split('/').length === 2) {
requestUrl += `GetList('${formatting.encodeQueryParameter(serverRelativeUrl)}')`;
}
else {
requestUrl += `GetFolderByServerRelativeUrl('${encodeURIComponent(serverRelativeUrl)}')/ListItemAllFields`;
}
`
Issue Analytics
- State:
- Created a year ago
- Comments:13 (13 by maintainers)
As far as I am concerned you can fix both in the same issue. 👍
But do please update the issue spec first so it’s clear what you are going to do.
@martinlingstuyl : I have updated the description of the issue to look more like a spec, please review .