1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-05-08 10:40:05 +00:00

Investigate how we can route a domain to a specific nuxt page

This commit is contained in:
Bram Wiepjes 2023-02-27 09:11:36 +00:00 committed by Jrmi
parent 870638fcb2
commit d269c35c07
19 changed files with 618 additions and 91 deletions
web-frontend/modules/builder/utils

View file

@ -0,0 +1,22 @@
import pathToRegexp from 'path-to-regexp'
export const resolveApplicationRoute = (application, fullPath) => {
let found
for (const page of application.pages) {
const keys = [] // Keys are populated by the next call
const re = pathToRegexp(page.path, keys)
const match = re.exec(fullPath)
if (match) {
// The page path has matched we can stop here our search and return the result
const [path, ...paramValues] = match
// TODO the parameter resolution here is really simple. Should be enough for a
// long time but we can do better here.
const params = Object.fromEntries(
paramValues.map((paramValue, index) => [keys[index].name, paramValue])
)
return [page, path, params]
}
}
return found
}