Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paths inside a router should be defined as relative #9

Open
alperozisik opened this issue Sep 29, 2018 · 3 comments
Open

Paths inside a router should be defined as relative #9

alperozisik opened this issue Sep 29, 2018 · 3 comments
Assignees
Labels
enhancement New feature or request task Task to complete

Comments

@alperozisik
Copy link

        StackRouter.of({
            path: "/pages",
            to: "/pages/page1",
            routes: [
                Route.of({
                    path: "/pages/page1",
                    build: (match, state, router) => new Page1(state.data, router)
                }),
                Route.of({
                    path: "/pages2/page3",  // <-- There pages2
                    build: (match, state, router, view) => {
                        return new Page2(Object.assign({ place: 2 }, state.data), router);
                    }
                })
            ]
        }),

This definition is not valid, also it should be possible. This is too prone to the Errors.
This item is important

@alperozisik alperozisik added enhancement New feature or request task Task to complete labels Sep 29, 2018
@alperozisik
Copy link
Author

So the root rooter should have default path as / when it is not set

@cenkce
Copy link
Contributor

cenkce commented Dec 19, 2018

in roadmap

@cenkce cenkce modified the milestones: 1.0.0, 1.1.0 Dec 19, 2018
@cenkce
Copy link
Contributor

cenkce commented Dec 19, 2018

and I can suggest :

var withParentPath = (parent) => (fn) => path => parent+'/'+(fn && fn(path) || path)

var root = withParentPath('/root')
var parent = withParentPath('parent')
var parent2 = withParentPath('parent2');
path = root(parent(parent2()))
path('child1') // "/root/parent/parent2/child1"

@cenkce cenkce removed this from the 1.1.0 milestone Dec 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request task Task to complete
Projects
None yet
Development

No branches or pull requests

2 participants