Review comments.

This commit is contained in:
mike12345567 2021-01-18 12:36:49 +00:00
parent 770dde61ec
commit 6be84b81b9
3 changed files with 5 additions and 3 deletions

View File

@ -62,7 +62,6 @@
if (urlIdx !== -1) { if (urlIdx !== -1) {
existingAppUrls.splice(urlIdx, 1) existingAppUrls.splice(urlIdx, 1)
} }
console.log(existingAppUrls)
nameValidation = { nameValidation = {
name: string() name: string()
.required(nameError) .required(nameError)

View File

@ -38,6 +38,8 @@ const {
HostingTypes, HostingTypes,
} = require("../../utilities/builder/hosting") } = require("../../utilities/builder/hosting")
const URL_REGEX_SLASH = /\/|\\/g
// utility function, need to do away with this // utility function, need to do away with this
async function getLayouts(db) { async function getLayouts(db) {
return ( return (
@ -72,7 +74,7 @@ async function getAppUrlIfNotInUse(ctx) {
} else { } else {
url = encodeURI(`${ctx.request.body.name}`) url = encodeURI(`${ctx.request.body.name}`)
} }
url = `/${url.replace(/\/|\\/g, "")}`.toLowerCase() url = `/${url.replace(URL_REGEX_SLASH, "")}`.toLowerCase()
const hostingInfo = await getHostingInfo() const hostingInfo = await getHostingInfo()
if (hostingInfo.type === HostingTypes.CLOUD) { if (hostingInfo.type === HostingTypes.CLOUD) {
return url return url

View File

@ -3,6 +3,7 @@ const CouchDB = require("../../db")
const env = require("../../environment") const env = require("../../environment")
const APP_PREFIX = "app_" const APP_PREFIX = "app_"
const URL_REGEX_SLASH = /\/|\\/g
exports.getApps = async ctx => { exports.getApps = async ctx => {
let allDbs let allDbs
@ -18,7 +19,7 @@ exports.getApps = async ctx => {
const body = {} const body = {}
for (let app of apps) { for (let app of apps) {
let url = app.url || encodeURI(`${app.name}`) let url = app.url || encodeURI(`${app.name}`)
url = `/${url.replace(/\/|\\/g, "")}` url = `/${url.replace(URL_REGEX_SLASH, "")}`
body[url] = { body[url] = {
appId: app._id, appId: app._id,
name: app.name, name: app.name,