Skip to content

Commit 93546a7

Browse files
author
Richard Gigan
committed
fix(FilePicker) : url build for root site vs collection site
1 parent aec4a5a commit 93546a7

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

src/services/OrgAssetsService.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)