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

Wildcard routing #766

Merged
merged 4 commits into from
Aug 6, 2020
Merged

Wildcard routing #766

merged 4 commits into from
Aug 6, 2020

Conversation

maier49
Copy link
Contributor

@maier49 maier49 commented Apr 30, 2020

Type: feature

The following has been addressed in the PR:

Description:
A proposed implementation of wildcard routing

  • A wildcard route is indicated by *. It will match a route normally up until the asterisk and then match anything after that.
  • A slightly higher penalty is imposed on the route score than for a route param, so that a more specific route will always win.
  • Introduces the wildcard route type and wildcardSegments to the RouteContext and MatchDetails. This will include all the segments of the path matched by the asterisk.
  • Adds additional checking for wildcard routes so that a change in route segments triggers a route change, even if the same wildcard route is still matched.

Resolves #330

@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 30, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit d6d1e81:

Sandbox Source
dojo/dojo-codesandbox-template Configuration

@codecov
Copy link

codecov bot commented Apr 30, 2020

Codecov Report

Merging #766 into master will increase coverage by 0.06%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #766      +/-   ##
==========================================
+ Coverage   97.53%   97.59%   +0.06%     
==========================================
  Files         127      127              
  Lines        7947     7981      +34     
  Branches     1828     1845      +17     
==========================================
+ Hits         7751     7789      +38     
+ Misses        196      192       -4     
Impacted Files Coverage Δ
src/core/vdom.ts 97.99% <100.00%> (+<0.01%) ⬆️
src/routing/Route.ts 94.28% <100.00%> (+11.42%) ⬆️
src/routing/Router.ts 100.00% <100.00%> (ø)
src/testing/assertRender.ts 95.86% <100.00%> (ø)
src/testing/harness/support/assertRender.ts 98.23% <100.00%> (ø)
src/testing/renderer.ts 97.64% <100.00%> (+0.06%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e548f88...d6d1e81. Read the comment docs.

@agubler
Copy link
Member

agubler commented Jun 26, 2020

@maier49 what would the behaviour be here for these two route configurations? Would foo/bar/1/2/3/4/5/qux match "foo/bar/*/qux" over the catch all "foo/bar/*"?

{
    path: "foo/bar/*/qux" 
},
{
    path: "foo/bar/*" 
}

@agubler
Copy link
Member

agubler commented Jun 26, 2020

I think these changes might need to be updated with master also

@maier49
Copy link
Contributor Author

maier49 commented Jun 29, 2020

@agubler With the implementation here it would just match whichever one is checked first. The wildcard section is explicitly treated as the final section of the route, anything past that is ignored.

@maier49 maier49 merged commit 9b889f5 into dojo:master Aug 6, 2020
@maier49 maier49 deleted the wildcard-routing branch August 6, 2020 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Route config support wildcard
2 participants