1
0
Fork 0
mirror of synced 2024-06-29 19:41:03 +12:00

Handle undefined url

This commit is contained in:
Rory Powell 2022-01-26 13:39:40 +00:00
parent 4b903ffd47
commit 2465753af1
4 changed files with 14 additions and 4 deletions

View file

@ -51,7 +51,7 @@ export const url = (validation, { apps, currentApp } = { apps: [] }) => {
}
return !apps
.map(app => app.url)
.some(appUrl => appUrl.toLowerCase() === value.toLowerCase())
.some(appUrl => appUrl?.toLowerCase() === value.toLowerCase())
}
)
.test("valid-url", "Not a valid URL", value => {

View file

@ -41,7 +41,11 @@
)
function getUrl(app) {
return `/app${app.url}`
if (app.url) {
return `/app${app.url}`
} else {
return `/${app.prodId}`
}
}
</script>

View file

@ -161,7 +161,11 @@
}
const viewApp = app => {
window.open(`/app${app.url}`)
if (app.url) {
window.open(`/app${app.url}`)
} else {
window.open(`/${app.prodId}`)
}
}
const editApp = app => {

View file

@ -43,7 +43,9 @@ async function getAppIdFromUrl(ctx) {
// search prod apps for a url that matches, exclude dev where id is always used
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) {
return app.appId