From 6d5d301adbccec400b92ff7e5de6e0362d6fab01 Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Wed, 5 Jan 2022 14:33:14 -0500 Subject: [PATCH] Support variables in URL --- .../[selectedDatasource]/rest/[query]/index.svelte | 8 ++++++-- packages/server/src/integrations/rest.ts | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/rest/[query]/index.svelte b/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/rest/[query]/index.svelte index 3af4fd2c48..c0e3bcea5e 100644 --- a/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/rest/[query]/index.svelte +++ b/packages/builder/src/pages/builder/app/[application]/data/datasource/[selectedDatasource]/rest/[query]/index.svelte @@ -232,8 +232,12 @@ const datasourceUrl = datasource?.config.url const qs = query?.fields.queryString breakQs = restUtils.breakQueryString(qs) - if (datasourceUrl && !query.fields.path?.startsWith(datasourceUrl)) { - const path = query.fields.path + const path = query.fields.path + if ( + datasourceUrl && + !path?.startsWith("http") && + !path?.startsWith("{{") // don't substitute the datasource url when query starts with a variable e.g. the upgrade path + ) { query.fields.path = `${datasource.config.url}/${path ? path : ""}` } url = buildUrl(query.fields.path, breakQs) diff --git a/packages/server/src/integrations/rest.ts b/packages/server/src/integrations/rest.ts index 63d7795a6d..06b4d327da 100644 --- a/packages/server/src/integrations/rest.ts +++ b/packages/server/src/integrations/rest.ts @@ -171,7 +171,7 @@ module RestModule { getUrl(path: string, queryString: string): string { const main = `${path}?${queryString}` let complete = main - if (this.config.url && !main.startsWith(this.config.url)) { + if (this.config.url && !main.startsWith("http")) { complete = !this.config.url ? main : `${this.config.url}/${main}` } if (!complete.startsWith("http")) {