mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 12:57:29 -08:00
⚡ 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.
This commit is contained in:
parent
3488edad7b
commit
a04ec2102c
|
@ -129,7 +129,7 @@ export async function getBaseAccessToken(this: IExecuteFunctions | ILoadOptionsF
|
||||||
|
|
||||||
export function resolveBaseUri(ctx: ICtx) {
|
export function resolveBaseUri(ctx: ICtx) {
|
||||||
return (ctx?.credentials?.environment === 'cloudHosted')
|
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) {
|
export function simplify(data: { results: IRow[] }, metadata: IDataObject) {
|
||||||
|
@ -292,3 +292,12 @@ export const split = (subject: string): string[] =>
|
||||||
.filter(s => s.length)
|
.filter(s => s.length)
|
||||||
.map(s => s.replace(/\\([\s\S])/gm, ($0, $1) => $1))
|
.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;
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in a new issue