From 3488edad7bcba725a28f97ba081094ea0e424711 Mon Sep 17 00:00:00 2001 From: Tom Klingenberg Date: Mon, 4 Oct 2021 12:10:39 +0200 Subject: [PATCH 1/3] :zap: Fix whitespace editorconfig highlights for seaTable node --- packages/nodes-base/nodes/SeaTable/Interfaces.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/nodes-base/nodes/SeaTable/Interfaces.ts b/packages/nodes-base/nodes/SeaTable/Interfaces.ts index 8d8357476b..4d8269edb2 100644 --- a/packages/nodes-base/nodes/SeaTable/Interfaces.ts +++ b/packages/nodes-base/nodes/SeaTable/Interfaces.ts @@ -93,9 +93,9 @@ export interface ICtx { export interface IRowResponse{ metadata: [ - { + { key: string, - name: string + name: string } ]; results: IRow[]; From a04ec2102ccfda500a3952bf5fe5e259843a8044 Mon Sep 17 00:00:00 2001 From: Tom Klingenberg Date: Mon, 4 Oct 2021 13:49:16 +0200 Subject: [PATCH 2/3] :zap: Fix common user-error Given a domain (the base-URI) in credentials terminated by a slash "/" is a common user-error when entering such data. Pass through userBaseUri() to trim slashes from the end of the string. --- .../nodes-base/nodes/SeaTable/GenericFunctions.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/nodes-base/nodes/SeaTable/GenericFunctions.ts b/packages/nodes-base/nodes/SeaTable/GenericFunctions.ts index 267e9390f1..4f39075bbd 100644 --- a/packages/nodes-base/nodes/SeaTable/GenericFunctions.ts +++ b/packages/nodes-base/nodes/SeaTable/GenericFunctions.ts @@ -129,7 +129,7 @@ export async function getBaseAccessToken(this: IExecuteFunctions | ILoadOptionsF export function resolveBaseUri(ctx: ICtx) { return (ctx?.credentials?.environment === 'cloudHosted') - ? 'https://cloud.seatable.io' : ctx?.credentials?.domain; + ? 'https://cloud.seatable.io' : userBaseUri(ctx?.credentials?.domain); } export function simplify(data: { results: IRow[] }, metadata: IDataObject) { @@ -292,3 +292,12 @@ export const split = (subject: string): string[] => .filter(s => s.length) .map(s => s.replace(/\\([\s\S])/gm, ($0, $1) => $1)) ; + +const userBaseUri = (str?: string) => { + if (str === undefined) { + return str; + } + let end = str.length; + for (; end > 0 && str[end - 1] === '/'; --end) {} + return end < str.length ? str.substring(0, end) : str; +}; From 3a497306750fb1b36f86b28e903e6ce8f1986b0d Mon Sep 17 00:00:00 2001 From: Jan Oberhauser Date: Thu, 7 Oct 2021 17:12:06 -0500 Subject: [PATCH 3/3] :zap: Simplify code --- .../nodes-base/nodes/SeaTable/GenericFunctions.ts | 15 +++++++++------ packages/nodes-base/nodes/SeaTable/Interfaces.ts | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/nodes-base/nodes/SeaTable/GenericFunctions.ts b/packages/nodes-base/nodes/SeaTable/GenericFunctions.ts index 4f39075bbd..70e139b983 100644 --- a/packages/nodes-base/nodes/SeaTable/GenericFunctions.ts +++ b/packages/nodes-base/nodes/SeaTable/GenericFunctions.ts @@ -293,11 +293,14 @@ export const split = (subject: string): string[] => .map(s => s.replace(/\\([\s\S])/gm, ($0, $1) => $1)) ; -const userBaseUri = (str?: string) => { - if (str === undefined) { - return str; +const userBaseUri = (uri?: string) => { + if (uri === undefined) { + return uri; } - let end = str.length; - for (; end > 0 && str[end - 1] === '/'; --end) {} - return end < str.length ? str.substring(0, end) : str; + + if (uri.endsWith('/')) { + return uri.slice(0, -1); + } + + return uri; }; diff --git a/packages/nodes-base/nodes/SeaTable/Interfaces.ts b/packages/nodes-base/nodes/SeaTable/Interfaces.ts index 4d8269edb2..d950d98be8 100644 --- a/packages/nodes-base/nodes/SeaTable/Interfaces.ts +++ b/packages/nodes-base/nodes/SeaTable/Interfaces.ts @@ -95,7 +95,7 @@ export interface IRowResponse{ metadata: [ { key: string, - name: string + name: string, } ]; results: IRow[];