Handle undefined url
This commit is contained in:
parent
f66a8b888f
commit
3d533d9f13
|
@ -51,7 +51,7 @@ export const url = (validation, { apps, currentApp } = { apps: [] }) => {
|
||||||
}
|
}
|
||||||
return !apps
|
return !apps
|
||||||
.map(app => app.url)
|
.map(app => app.url)
|
||||||
.some(appUrl => appUrl.toLowerCase() === value.toLowerCase())
|
.some(appUrl => appUrl?.toLowerCase() === value.toLowerCase())
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.test("valid-url", "Not a valid URL", value => {
|
.test("valid-url", "Not a valid URL", value => {
|
||||||
|
|
|
@ -41,7 +41,11 @@
|
||||||
)
|
)
|
||||||
|
|
||||||
function getUrl(app) {
|
function getUrl(app) {
|
||||||
|
if (app.url) {
|
||||||
return `/app${app.url}`
|
return `/app${app.url}`
|
||||||
|
} else {
|
||||||
|
return `/${app.prodId}`
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -161,7 +161,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const viewApp = app => {
|
const viewApp = app => {
|
||||||
|
if (app.url) {
|
||||||
window.open(`/app${app.url}`)
|
window.open(`/app${app.url}`)
|
||||||
|
} else {
|
||||||
|
window.open(`/${app.prodId}`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const editApp = app => {
|
const editApp = app => {
|
||||||
|
|
|
@ -43,7 +43,9 @@ async function getAppIdFromUrl(ctx) {
|
||||||
|
|
||||||
// search prod apps for a url that matches, exclude dev where id is always used
|
// search prod apps for a url that matches, exclude dev where id is always used
|
||||||
const apps = await getAllApps(CouchDB, { dev: false })
|
const apps = await getAllApps(CouchDB, { dev: false })
|
||||||
const app = apps.filter(a => a.url.toLowerCase() === possibleAppUrl)[0]
|
const app = apps.filter(
|
||||||
|
a => a.url && a.url.toLowerCase() === possibleAppUrl
|
||||||
|
)[0]
|
||||||
|
|
||||||
if (app && app.appId) {
|
if (app && app.appId) {
|
||||||
return app.appId
|
return app.appId
|
||||||
|
|
Loading…
Reference in New Issue