@@ -13,17 +13,27 @@ export class OrgAssetsService extends FileBrowserService {
1313 public getListItems = async ( listUrl : string , folderPath : string , acceptedFilesExtensions ?: string [ ] , nextPageQueryStringParams ?: string ) : Promise < FilesQueryResult > => {
1414 let filesQueryResult : FilesQueryResult = { items : [ ] , nextHref : null } ;
1515 try {
16- // Retrieve Lib path from folder path
1716
18- if ( folderPath . charAt ( 0 ) === "/" ) {
19- folderPath = folderPath . substring ( 1 ) ;
17+ // Retrieve Lib path from folder path
18+ const isRootSite = this . context . pageContext . site . serverRelativeUrl === '/' ;
19+
20+ if ( ! isRootSite ) {
21+ if ( folderPath . charAt ( 0 ) !== '/' ) {
22+ folderPath = `/${ folderPath } ` ;
23+ }
24+
25+ } else {
26+ if ( folderPath . charAt ( 0 ) === '/' ) {
27+ folderPath = folderPath . substring ( 1 ) ;
28+ }
2029 }
21-
30+
2231 // Remove all the rest of the folder path
23- let libName = folderPath ; //.replace(`${this._orgAssetsLibraryServerRelativeSiteUrl}/`, "");
24- //libName = libName.split("/")[0];
25- // Buil absolute library URL
26- const libFullUrl = this . buildAbsoluteUrl ( `${ this . _orgAssetsLibraryServerRelativeSiteUrl } ${ libName } ` ) ;
32+ let libName = folderPath . replace ( `${ this . _orgAssetsLibraryServerRelativeSiteUrl } /` , '' ) ;
33+ libName = libName . split ( '/' ) [ 0 ] ;
34+
35+ // Build absolute library URL
36+ const libFullUrl = this . buildAbsoluteUrl ( ! isRootSite ? `${ this . _orgAssetsLibraryServerRelativeSiteUrl } /${ libName } ` : `${ this . _orgAssetsLibraryServerRelativeSiteUrl } ${ libName } ` ) ;
2737
2838 let queryStringParams : string = "" ;
2939 // Do not pass FolderServerRelativeUrl as query parameter
0 commit comments