Description
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`;
}
`
Description
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:
const serverRelativeUrl: string = urlUtil.getServerRelativePath(args.options.webUrl, args.options.folderUrl);to handle different ways the folderUrl value can be passed, i.e.
const roleFolderUrl: string = urlUtil.getWebRelativePath(args.options.webUrl, args.options.folderUrl); let requestUrl: string =${args.options.webUrl}/_api/web/`;`