Allow matching newlines in splat portions of paths #11221
Replies: 7 comments 3 replies
-
👍 The space example in this is a duplicate of #10814 and has a fix prepared (and an experimental you can test against - see this comment) Could you elaborate on your use-case for needing a newline in the path? That's a different underlying issue - not encoding related. It's that we currently use a dot ( I'm unsure if we'll want to change those underlying regexes without a compelling reason to include newlines in paths? For the time being you can use |
Beta Was this translation helpful? Give feedback.
-
Great, I'll test that out shortly and let you know how it goes. It seems like newlines should be supported, since they are valid characters in paths. My specific case is I use user generated database object names in paths for my app, which can contain newlines (though I have no idea why you would want to do this!). It's definitely an edge case, but I don't see a downside to supporting it. |
Beta Was this translation helpful? Give feedback.
-
Is it possible to strip the newlines prior to generating the routes or replace them with
Totally agree - this is my main concern with adding support. Seems like it's a very small edge case so very little benefit to React Router apps as a whole - and introduces some level of risk by making regexes newline-inclusive. I think I'd prefer to move this to a Proposal Discussion if you're interested and if it gains enough traction there we can reconsider. |
Beta Was this translation helpful? Give feedback.
-
We could definitely handle this in our code, but I feel like it's an odd limitation that is pretty arbitrary. I'm happy to move it to a proposal, did you want me to create that? |
Beta Was this translation helpful? Give feedback.
-
I can actually just convert this over directly so we retain the context 👍 . In the meantime you could also give the |
Beta Was this translation helpful? Give feedback.
-
Thanks for moving this to a discussion! Just to restate my thoughts on this: React router is the most widely used router, and generally offers a ton of flexibility for users to build any sort of routing structure they can think of. I know from following Remix that you all are big fans of using platform standards as much as possible. Given that a newline, percent encoded as Another question worth asking here: what is the downside to supporting newlines? As Matt already pointed out, it's easy enough to use |
Beta Was this translation helpful? Give feedback.
-
I just discovered another bug in this same class of issues: path segments with |
Beta Was this translation helpful? Give feedback.
-
What version of React Router are you using?
6.21.1
Steps to Reproduce
When using relative child routes in separate components (a route renders a component that has its own
Routes
), whitespace seems to cause routes not to match when they should.The vite dev server will pick a random port, open that url and click the various links on the page. Notice that "working path" displays
name : "bar"
, but the two broken paths do not.Expected Behavior
Both of the broken paths should render the
Name
component, since%20
and%0A
are valid path segements.Actual Behavior
When there is a trailing space, the deepest child is not rendered. In the newline case, the whole tree of routes is unmounted.
Beta Was this translation helpful? Give feedback.
All reactions