Handle undefined url
This commit is contained in:
parent
4b903ffd47
commit
2465753af1
|
@ -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) {
|
||||||
return `/app${app.url}`
|
if (app.url) {
|
||||||
|
return `/app${app.url}`
|
||||||
|
} else {
|
||||||
|
return `/${app.prodId}`
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -161,7 +161,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const viewApp = app => {
|
const viewApp = app => {
|
||||||
window.open(`/app${app.url}`)
|
if (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