Skip to content

Commit

Permalink
fix(Microsoft Excel 365 Node): Ensure arg is string during worksheet …
Browse files Browse the repository at this point in the history
…table search (#8154)

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

---------

Co-authored-by: Michael Kret <michael.k@radency.com>
  • Loading branch information
ivov and michael-radency authored Jan 2, 2024
1 parent e126ed7 commit 8e873ca
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions packages/nodes-base/nodes/Microsoft/Excel/v2/methods/listSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export async function getWorksheetsList(
): Promise<INodeListSearchResult> {
const workbookRLC = this.getNodeParameter('workbook') as IDataObject;
const workbookId = workbookRLC.value as string;
let workbookURL = workbookRLC.cachedResultUrl as string;
let workbookURL = (workbookRLC.cachedResultUrl as string) ?? '';

if (workbookURL.includes('1drv.ms')) {
workbookURL = `https://onedrive.live.com/edit.aspx?resid=${workbookId}`;
Expand All @@ -91,7 +91,9 @@ export async function getWorksheetsList(
results: (response.value as IDataObject[]).map((worksheet: IDataObject) => ({
name: worksheet.name 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,
})),
};
}
Expand All @@ -101,7 +103,7 @@ export async function getWorksheetTables(
): Promise<INodeListSearchResult> {
const workbookRLC = this.getNodeParameter('workbook') as IDataObject;
const workbookId = workbookRLC.value as string;
let workbookURL = workbookRLC.cachedResultUrl as string;
let workbookURL = (workbookRLC.cachedResultUrl as string) ?? '';

if (workbookURL.includes('1drv.ms')) {
workbookURL = `https://onedrive.live.com/edit.aspx?resid=${workbookId}`;
Expand Down Expand Up @@ -138,9 +140,12 @@ export async function getWorksheetTables(

const [sheetName, sheetRange] = address.split('!' as string);

const url = `${workbookURL}&activeCell=${encodeURIComponent(sheetName as string)}${
sheetRange ? '!' + (sheetRange as string) : ''
}`;
let url;
if (workbookURL) {
url = `${workbookURL}&activeCell=${encodeURIComponent(sheetName as string)}${
sheetRange ? '!' + (sheetRange as string) : ''
}`;
}

results.push({ name, value, url });
}
Expand Down

0 comments on commit 8e873ca

Please sign in to comment.