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

Map url with trailing slash to edit #63

Closed
MichaelBuen opened this issue Aug 3, 2017 · 4 comments
Closed

Map url with trailing slash to edit #63

MichaelBuen opened this issue Aug 3, 2017 · 4 comments

Comments

@MichaelBuen
Copy link

MichaelBuen commented Aug 3, 2017

Currently, with this routesMap:

COMPANY_LIST: { path: '/company', thunk: thunkList },
COMPANY_FORM: { path: '/company/:companyCode', thunk: thunkForm }, 

The url /company/ maps to COMPANY_LIST instead of to COMPANY_FORM.

Could we make /company/ maps to COMPANY_FORM instead?

Having used angular ui-router, it could facilitate this kind of url idiom for list, new, and edit:

/company 
/company/
/company/fb

Or we could keep /company and /company/ maps to same route, but could we have a way to configure that /company/ and /company/:companyCode maps to same route?

@faceyspacey
Copy link
Owner

hmm... I'm pretty much relying on path-to-regexp, but I'm sure it could be customized.

So basically the slash triggers a route with a param after the slash.

Is this 100% the idiom here, or just specific to angular ui-router? Doesn't React Router handle it like RFR handles it? That's why they have the strict option, which we also have in our <Link /> package.

I personally don't like that slash making such a big difference. I'd prefer the new route to be /company/create or something.

But it's really whatever is truly standard here that we should be doing.

@MichaelBuen
Copy link
Author

MichaelBuen commented Aug 5, 2017

Haven't used React Router yet. Redux First Router is my router of choice for React, state-based routing is better than physically routing components to urls, and I didn't struggle making code-splitting work via RFR's thunk.

I think it's not specific to angular ui-router, tried the older version of React Router now, /company/ and /company/fb maps to same route: /company/:companyCode.

https://fiddle.jshell.net/jcdasrn2/

Tried the new version (React Router 4), the behavior is now different though, both /company/ and /company maps as same route. Haven't checked yet if it can be configured to make it behave like its older version.

https://codepen.io/anon/pen/PKWwxe

@faceyspacey
Copy link
Owner

glad to hear that RFR is your router of choice lol!

I really don't think I'll be able to do much about this one brother, especially if RR4 is also doing it by default. Just FYI. But thanks for researching this, it's basically a PR you provided. Makes the decision here.

@faceyspacey
Copy link
Owner

I'm going to close this for now. Feel free to re-open if you need.

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

No branches or pull requests

2 participants