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

Route config support wildcard #330

Closed
xiaohulu opened this issue May 5, 2019 · 1 comment · Fixed by #766
Closed

Route config support wildcard #330

xiaohulu opened this issue May 5, 2019 · 1 comment · Fixed by #766
Assignees
Labels
area: routing Routing discussion The issue is up for discussion enhancement New feature or request

Comments

@xiaohulu
Copy link
Contributor

xiaohulu commented May 5, 2019

Enhancement

Package Version: 5.0

I want design a REST API {owner}/{project}/tree/{branch}/* to view the folder structure.

|- root
    |- folder1
          |- folder2
                 |- folder3
                        |- file1
  1. use {owner}/{project}/tree/{branch} to get folder1
  2. use {owner}/{project}/tree/{branch}/folder1 to get folder2
  3. use {owner}/{project}/tree/{branch}/folder1/folder2 to get folder3

It is similar to github's repo url.

Code

I use router config like below first

{
    "path": "{owner}/{project}/tree/{branch}/{folderPathes}",
    "outlet": "view-project-tree"
}

folderPathes can be empty or null, 'folder1', 'folder1/folder2' which contains /

But the router can not switch '{owner}/{project}/tree/{branch}/folder1' to '{owner}/{project}/tree/{branch}/folder1/folder2'

may be here do a check

https://github.com/dojo/framework/blob/master/src/routing/Router.ts#L244

if (route.segments[segmentIndex] === undefined) {
    type = 'partial';
    break;
}

because route.segments length is greater than params length

So I expect to support wildcard like this

{
    "path": "{owner}/{project}/tree/{branch}/*",
    "outlet": "view-project-tree"
}

Expected behavior:

{
    "path": "tree/*",
    "outlet": "view-tree"
}

* can be zero or more segments

  1. if view the root folder, then the path is tree, not include the ending /
  2. if view the second level, then the path is tree/folder1
  3. if view the third level, then the path is tree/folder1/folder2
  4. ...
@xiaohulu
Copy link
Contributor Author

May be, route config should be nested router.

{
    "path": "tree",
    "outlet": "view-tree-root",
    "children": [
        {
            "path": "*", 
            "outlet": "view-tree-children"
        }
    ]
}

which can partial refresh the tree part.

@agubler agubler mentioned this issue Sep 10, 2019
@agubler agubler added area: routing Routing discussion The issue is up for discussion enhancement New feature or request labels Jan 30, 2020
@maier49 maier49 self-assigned this Apr 29, 2020
@maier49 maier49 mentioned this issue Apr 30, 2020
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: routing Routing discussion The issue is up for discussion enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants