Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
 into dev
  • Loading branch information
joaojmendes committed Apr 17, 2024
2 parents 9216b53 + db773cc commit 44b13de
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/services/OrgAssetsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,20 @@ export class OrgAssetsService extends FileBrowserService {
public getListItemsByListId = async (listId: string, folderPath: string, acceptedFilesExtensions?: string[], nextPageQueryStringParams?: string): Promise<FilesQueryResult> => {
let filesQueryResult: FilesQueryResult = { items: [], nextHref: null };
try {
let orgAssetLibraryServerRelativeUrlWithoutTrailingSlash = this._orgAssetsLibraryServerRelativeSiteUrl;
if (orgAssetLibraryServerRelativeUrlWithoutTrailingSlash.charAt(orgAssetLibraryServerRelativeUrlWithoutTrailingSlash.length - 1) === '/') {
orgAssetLibraryServerRelativeUrlWithoutTrailingSlash = orgAssetLibraryServerRelativeUrlWithoutTrailingSlash.slice(0, -1);
}

// Retrieve Lib path from folder path
if (folderPath.charAt(0) !== "/") {
folderPath = `/${folderPath}`;
}
// Remove all the rest of the folder path
let libName = folderPath.replace(`${this._orgAssetsLibraryServerRelativeSiteUrl}/`, "");
libName = libName.split("/")[0];
// Buil absolute library URL
const libFullUrl = this.buildAbsoluteUrl(`${this._orgAssetsLibraryServerRelativeSiteUrl}/${libName}`);
let libName = folderPath.replace(`${orgAssetLibraryServerRelativeUrlWithoutTrailingSlash}/`, "");
libName = libName.split("/")[0]; // Get only library name, if navigated to sub folder in the picker
// Build absolute library URL
const libFullUrl = this.buildAbsoluteUrl(`${orgAssetLibraryServerRelativeUrlWithoutTrailingSlash}/${libName}`);

let queryStringParams: string = "";
// Do not pass FolderServerRelativeUrl as query parameter
Expand Down Expand Up @@ -104,7 +109,7 @@ export class OrgAssetsService extends FileBrowserService {

private _parseOrgAssetsLibraryItem = (libItem: any): ILibrary => { // eslint-disable-line @typescript-eslint/no-explicit-any
const orgAssetsLibrary: ILibrary = {
absoluteUrl: this.buildAbsoluteUrl(libItem.LibraryUrl.DecodedUrl),
absoluteUrl: this.buildAbsoluteUrl(`/${libItem.LibraryUrl.DecodedUrl}`),
title: libItem.DisplayName,
id: libItem.ListId,
serverRelativeUrl: libItem.LibraryUrl.DecodedUrl,
Expand Down

0 comments on commit 44b13de

Please sign in to comment.