fix(Microsoft Excel 365 Node): Support for more extensions in workbook rlc (#7020)

Github issue / Community forum post (link here to close automatically):
This commit is contained in:
Michael Kret 2023-08-25 16:37:34 +03:00 committed by GitHub
parent 0356419c1a
commit d6e1cf232f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -11,7 +11,10 @@ export async function searchWorkbooks(
filter?: string, filter?: string,
paginationToken?: string, paginationToken?: string,
): Promise<INodeListSearchResult> { ): Promise<INodeListSearchResult> {
const q = filter ? encodeURI(`.xlsx AND ${filter}`) : '.xlsx'; const fileExtensions = ['.xlsx', '.xlsm', '.xlst'];
const extensionFilter = fileExtensions.join(' OR ');
const q = filter || extensionFilter;
let response: IDataObject = {}; let response: IDataObject = {};
@ -37,10 +40,22 @@ export async function searchWorkbooks(
); );
} }
if (response.value && filter) {
response.value = (response.value as IDataObject[]).filter((workbook: IDataObject) => {
return fileExtensions.some((extension) => (workbook.name as string).includes(extension));
});
}
return { return {
results: (response.value as IDataObject[]).map((workbook: IDataObject) => { results: (response.value as IDataObject[]).map((workbook: IDataObject) => {
for (const extension of fileExtensions) {
if ((workbook.name as string).includes(extension)) {
workbook.name = (workbook.name as string).replace(extension, '');
break;
}
}
return { return {
name: (workbook.name as string).replace('.xlsx', ''), name: workbook.name as string,
value: workbook.id as string, value: workbook.id as string,
url: workbook.webUrl as string, url: workbook.webUrl as string,
}; };