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:
parent
870638fcb2
commit
d269c35c07
19 changed files with 618 additions and 91 deletions
web-frontend/modules/builder/utils
22
web-frontend/modules/builder/utils/routing.js
Normal file
22
web-frontend/modules/builder/utils/routing.js
Normal 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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue