fix(Microsoft Excel 365 Node): Ensure arg is string during worksheet table search (#8154)

https://n8nio.sentry.io/issues/4748574897

---------

Co-authored-by: Michael Kret <michael.k@radency.com>
This commit is contained in:
Iván Ovejero 2024-01-02 10:07:12 +01:00 committed by GitHub
parent e126ed74f3
commit 8e873ca2f3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -69,7 +69,7 @@ export async function getWorksheetsList(
): Promise<INodeListSearchResult> { ): Promise<INodeListSearchResult> {
const workbookRLC = this.getNodeParameter('workbook') as IDataObject; const workbookRLC = this.getNodeParameter('workbook') as IDataObject;
const workbookId = workbookRLC.value as string; const workbookId = workbookRLC.value as string;
let workbookURL = workbookRLC.cachedResultUrl as string; let workbookURL = (workbookRLC.cachedResultUrl as string) ?? '';
if (workbookURL.includes('1drv.ms')) { if (workbookURL.includes('1drv.ms')) {
workbookURL = `https://onedrive.live.com/edit.aspx?resid=${workbookId}`; workbookURL = `https://onedrive.live.com/edit.aspx?resid=${workbookId}`;
@ -91,7 +91,9 @@ export async function getWorksheetsList(
results: (response.value as IDataObject[]).map((worksheet: IDataObject) => ({ results: (response.value as IDataObject[]).map((worksheet: IDataObject) => ({
name: worksheet.name as string, name: worksheet.name as string,
value: worksheet.id as string, value: worksheet.id as string,
url: `${workbookURL}&activeCell=${encodeURIComponent(worksheet.name as string)}!A1`, url: workbookURL
? `${workbookURL}&activeCell=${encodeURIComponent(worksheet.name as string)}!A1`
: undefined,
})), })),
}; };
} }
@ -101,7 +103,7 @@ export async function getWorksheetTables(
): Promise<INodeListSearchResult> { ): Promise<INodeListSearchResult> {
const workbookRLC = this.getNodeParameter('workbook') as IDataObject; const workbookRLC = this.getNodeParameter('workbook') as IDataObject;
const workbookId = workbookRLC.value as string; const workbookId = workbookRLC.value as string;
let workbookURL = workbookRLC.cachedResultUrl as string; let workbookURL = (workbookRLC.cachedResultUrl as string) ?? '';
if (workbookURL.includes('1drv.ms')) { if (workbookURL.includes('1drv.ms')) {
workbookURL = `https://onedrive.live.com/edit.aspx?resid=${workbookId}`; workbookURL = `https://onedrive.live.com/edit.aspx?resid=${workbookId}`;
@ -138,9 +140,12 @@ export async function getWorksheetTables(
const [sheetName, sheetRange] = address.split('!' as string); const [sheetName, sheetRange] = address.split('!' as string);
const url = `${workbookURL}&activeCell=${encodeURIComponent(sheetName as string)}${ let url;
if (workbookURL) {
url = `${workbookURL}&activeCell=${encodeURIComponent(sheetName as string)}${
sheetRange ? '!' + (sheetRange as string) : '' sheetRange ? '!' + (sheetRange as string) : ''
}`; }`;
}
results.push({ name, value, url }); results.push({ name, value, url });
} }