1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionpack/lib/action_dispatch/journey
Adam Hess 98ed2406f7 cause rails to correctly place optional path parameters
previously, if you specify a url parameter that is part of the path as false it would include that part of the path as parameter at the end of the url instead of in the path for example:
`get "(/optional/:optional_id)/things" => "foo#foo", as: :things`
`things_path(optional_id: false)  # => /things?optional_id=false`

this is not the case for empty string,
`things_path(optional_id: '')  # => "/things"

this is due to a quark in how path parameters get removed from the parameters.

we where doing `(paramter || recall).nil?` which returns nil if both values are nil however it also return nil if one value is false and the other value is nil. i.e. `(false || nil).nil # => nil` which is confusing.

After this change, `true` and `false` will be treated the same when used as optional path parameters. meaning now,

```
get '(this/:my_bool)/that' as: :that

that_path(my_bool: true) # => `/this/true/that`
that_path(my_bool: false) # => `/this/false/that`
```
fixes: https://github.com/rails/rails/issues/42280

Co-authored-by: Ryuta Kamizono <kamipo@gmail.com>
2021-05-27 18:21:01 -07:00
..
gtg Enable Performance/MapCompact cop 2021-04-23 16:33:02 +09:00
nfa Remove unused journey code 2020-04-25 00:40:37 +09:00
nodes actionpack: Improve performance by allowing routes with custom regexes in the FSM. 2021-01-06 09:54:44 +11:00
path Fix issue routing with optional parts of a segment 2021-01-12 14:30:59 -08:00
router Update actionpack/lib/action_dispatch/journey/router/utils.rb 2021-02-04 14:07:34 -03:00
visualizer Merge pull request #41919 from jbampton/fix-html-script-tag 2021-04-12 07:30:51 +09:00
formatter.rb cause rails to correctly place optional path parameters 2021-05-27 18:21:01 -07:00
parser.rb Build symbols descending from stars with regexp 2020-07-24 22:30:20 -04:00
parser.y Build symbols descending from stars with regexp 2020-07-24 22:30:20 -04:00
parser_extras.rb
route.rb actionpack: Improve performance by allowing routes with custom regexes in the FSM. 2021-01-06 09:54:44 +11:00
router.rb actionpack: Improve performance by allowing routes with custom regexes in the FSM. 2021-01-06 09:54:44 +11:00
routes.rb actionpack: Improve performance by allowing routes with custom regexes in the FSM. 2021-01-06 09:54:44 +11:00
scanner.rb Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
visitors.rb cause rails to correctly place optional path parameters 2021-05-27 18:21:01 -07:00