@@ -13,17 +13,27 @@ export class OrgAssetsService extends FileBrowserService {
13
13
public getListItems = async ( listUrl : string , folderPath : string , acceptedFilesExtensions ?: string [ ] , nextPageQueryStringParams ?: string ) : Promise < FilesQueryResult > => {
14
14
let filesQueryResult : FilesQueryResult = { items : [ ] , nextHref : null } ;
15
15
try {
16
- // Retrieve Lib path from folder path
17
16
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
+ }
20
29
}
21
-
30
+
22
31
// 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 } ` ) ;
27
37
28
38
let queryStringParams : string = "" ;
29
39
// Do not pass FolderServerRelativeUrl as query parameter
0 commit comments