Redwood: [Router] Routes allow spaces but fail on them

Created on 2 Apr 2020  路  6Comments  路  Source: redwoodjs/redwood

The /\{([^}]+)\}/g regexp that's widely used in the router's implementation allows spaces in param names and types, as well as before or after the colon.

However, the rest of the code is not prepared for spaces within the type names: trying to match the route /posts/{id: Int} will fail trying to look for a " Int" type within the known types...

Happy to open a PR to change that, however I'm wondering how you'd treat the issue:

  • Disallow spaces in route params
  • or be space-proof in route processing?

Personally, I'd vote for the former, as that'd make it easier to have a single way of doing things, and who wants a /route/{my param: Int} anyway?

router

All 6 comments

Personally, I'd vote for the former

100% agree with you.

As a new learner, I'd say my vote is for the former, as well. Spaces don't seem natural in a URL, so disallowing them seems natural, too.

Agreed. No spaces!

Perfect then, I鈥檒l start a PR ASAP!

@olance no pressure or rush here, but checking in to see if the PR did get started. Just didn鈥檛 want this one to get lost or remain open if fix is already complete.

@thedavidprice yeah sorry work as been crazier recently so didn't have time for Redwood 馃槙
But I'm still planning on pushing a PR! Hopefully this week-end 馃

Was this page helpful?
0 / 5 - 0 ratings

Related issues

CR1AT0RS picture CR1AT0RS  路  4Comments

weaversam8 picture weaversam8  路  3Comments

aldonline picture aldonline  路  3Comments

jtoar picture jtoar  路  4Comments

freddydumont picture freddydumont  路  3Comments