From 6be84b81b977e19cbbc46d82a839deb4ff513567 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Mon, 18 Jan 2021 12:36:49 +0000 Subject: [PATCH] Review comments. --- packages/builder/src/components/settings/tabs/General.svelte | 1 - packages/server/src/api/controllers/application.js | 4 +++- packages/worker/src/api/controllers/app.js | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/builder/src/components/settings/tabs/General.svelte b/packages/builder/src/components/settings/tabs/General.svelte index 624ca9d617..9e9daf5f57 100644 --- a/packages/builder/src/components/settings/tabs/General.svelte +++ b/packages/builder/src/components/settings/tabs/General.svelte @@ -62,7 +62,6 @@ if (urlIdx !== -1) { existingAppUrls.splice(urlIdx, 1) } - console.log(existingAppUrls) nameValidation = { name: string() .required(nameError) diff --git a/packages/server/src/api/controllers/application.js b/packages/server/src/api/controllers/application.js index eda2a77ee0..ba381974a8 100644 --- a/packages/server/src/api/controllers/application.js +++ b/packages/server/src/api/controllers/application.js @@ -38,6 +38,8 @@ const { HostingTypes, } = require("../../utilities/builder/hosting") +const URL_REGEX_SLASH = /\/|\\/g + // utility function, need to do away with this async function getLayouts(db) { return ( @@ -72,7 +74,7 @@ async function getAppUrlIfNotInUse(ctx) { } else { url = encodeURI(`${ctx.request.body.name}`) } - url = `/${url.replace(/\/|\\/g, "")}`.toLowerCase() + url = `/${url.replace(URL_REGEX_SLASH, "")}`.toLowerCase() const hostingInfo = await getHostingInfo() if (hostingInfo.type === HostingTypes.CLOUD) { return url diff --git a/packages/worker/src/api/controllers/app.js b/packages/worker/src/api/controllers/app.js index 114970a61b..eac0c47c18 100644 --- a/packages/worker/src/api/controllers/app.js +++ b/packages/worker/src/api/controllers/app.js @@ -3,6 +3,7 @@ const CouchDB = require("../../db") const env = require("../../environment") const APP_PREFIX = "app_" +const URL_REGEX_SLASH = /\/|\\/g exports.getApps = async ctx => { let allDbs @@ -18,7 +19,7 @@ exports.getApps = async ctx => { const body = {} for (let app of apps) { let url = app.url || encodeURI(`${app.name}`) - url = `/${url.replace(/\/|\\/g, "")}` + url = `/${url.replace(URL_REGEX_SLASH, "")}` body[url] = { appId: app._id, name: app.name,