aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/journey
Commit message (Collapse)AuthorAgeFilesLines
* Enable `Layout/EmptyLinesAroundAccessModifier` copRyuta Kamizono2019-06-139-11/+0
| | | | | | | | | | | We sometimes say "✂️ newline after `private`" in a code review (e.g. https://github.com/rails/rails/pull/18546#discussion_r23188776, https://github.com/rails/rails/pull/34832#discussion_r244847195). Now `Layout/EmptyLinesAroundAccessModifier` cop have new enforced style `EnforcedStyle: only_before` (https://github.com/rubocop-hq/rubocop/pull/7059). That cop and enforced style will reduce the our code review cost.
* Remove Route#build as it wasn't usedAlberto Almagro2019-05-221-7/+1
| | | | | | After @kamipo CR feedback we realized `Route#build` wasn't used. As it is also private API being able to create Routes both with `#new` and `#build` was redundant.
* Use keyword arguments for ActionDispatch::Journey:Route constructorAlberto Almagro2019-05-221-3/+4
| | | | | | | | | | This commit changes from constructor's argument list to keyword arguments in order to remove the dependency of remember parameters' positions. The constructor already provided a default value for `internal`, this commits takes the chance to also add default values for `precedence` and `scope_options`.
* Keep part when scope option has valueAlberto Almagro2019-05-222-5/+6
| | | | | | | | | When a route was defined within an optional scope, if that route didn't take parameters the scope was lost when using path helpers. This patch ensures scope is kept both when the route takes parameters or when it doesn't. Fixes #33219
* Merge pull request #35975 from xithan/masterRafael França2019-04-151-1/+2
|\ | | | | mounted routes with non-word characters
| * mounted routes with non-word charactersxithan2019-04-151-1/+2
| |
* | Adds named_captures to MatchData to emulate RegexBrandon Weaver2019-04-091-0/+4
|/ | | | | | | | | This change adds a `named_captures` method to `ActionDispatch::Journey::Path::MatchData` in order to emulate a similar method present on `Regex`'s `MatchData` present in Ruby core. This method can be useful for introspection of routes without the need to use `zip` while testing or developing in Rails core.
* `ast` is no longer to be `nil` since #33118Ryuta Kamizono2019-04-051-1/+0
|
* Restrict matching with word boundary or end of stringPetri Avikainen2019-02-051-1/+1
|
* Define word boundary for unanchored path regexpPetri Avikainen2019-02-051-1/+1
|
* Expand metaprogramming for Symbol, Slash and Dot.Alberto Almagro2018-12-071-6/+7
| | | | | | | | | | | | | | This first started with moving type method inside `ActionDispatch::Journey::Nodes::Symbol`. `AD::Journey::Nodes::Symbol#type` was generated dynamically with an `each` block. While this is OK for classes like `AD::Journey::Nodes::Slash` or `AD::Journey::Nodes::Dot` which don't have further implementation, all other classes containing more logic have this method defined in their class body. This patch does the same in this case. On code review process @kamipo suggested to fully expand over metaprogramming for Slash and Dot classes, a topic on which I agree with him.
* Remove unused `Journey::Router::RoutingError`yuuji.yaginuma2018-11-181-3/+0
| | | | `Journey::Router::RoutingError` is no longer used since db06d128262b49c8b02e153cf95eb46f4eff364b.
* Add `Style/RedundantFreeze` to remove redudant `.freeze`Yasuo Honda2018-09-292-9/+9
| | | | | | | | | | | | | | | | | | | | | Since Rails 6.0 will support Ruby 2.4.1 or higher `# frozen_string_literal: true` magic comment is enough to make string object frozen. This magic comment is enabled by `Style/FrozenStringLiteralComment` cop. * Exclude these files not to auto correct false positive `Regexp#freeze` - 'actionpack/lib/action_dispatch/journey/router/utils.rb' - 'activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb' It has been fixed by https://github.com/rubocop-hq/rubocop/pull/6333 Once the newer version of RuboCop released and available at Code Climate these exclude entries should be removed. * Replace `String#freeze` with `String#-@` manually if explicit frozen string objects are required - 'actionpack/test/controller/test_case_test.rb' - 'activemodel/test/cases/type/string_test.rb' - 'activesupport/lib/active_support/core_ext/string/strip.rb' - 'activesupport/test/core_ext/string_ext_test.rb' - 'railties/test/generators/actions_test.rb'
* Enable `Performance/UnfreezeString` copyuuji.yaginuma2018-09-232-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Ruby 2.3 or later, `String#+@` is available and `+@` is faster than `dup`. ```ruby # frozen_string_literal: true require "bundler/inline" gemfile(true) do source "https://rubygems.org" gem "benchmark-ips" end Benchmark.ips do |x| x.report('+@') { +"" } x.report('dup') { "".dup } x.compare! end ``` ``` $ ruby -v benchmark.rb ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux] Warming up -------------------------------------- +@ 282.289k i/100ms dup 187.638k i/100ms Calculating ------------------------------------- +@ 6.775M (± 3.6%) i/s - 33.875M in 5.006253s dup 3.320M (± 2.2%) i/s - 16.700M in 5.032125s Comparison: +@: 6775299.3 i/s dup: 3320400.7 i/s - 2.04x slower ```
* Merge pull request #33054 from jboler/masterRafael França2018-07-031-0/+1
|\ | | | | Fix route eager loading
| * Only build routes simulator when there is an ASTJonathan Boler2018-06-041-0/+1
| |
* | Fix bug with eager_load in development environmentDan Jensen2018-06-111-1/+1
|/ | | | | Modifies the routes simulator to allow for empty RouteSets, which are created when secondary Engines are loaded.
* Remove 7 years old note-to-self by tenderloveutilum2018-05-221-2/+0
| | | | | | Introduced in rails/journey@a806beb [ci skip]
* Fix array routing constraintsfatkodima2018-02-171-2/+2
|
* Write the code in a more natural way.Rafael Mendonça França2018-02-161-2/+2
|
* PERF: reduce retained objects in JourneySam2018-02-161-2/+2
| | | | | | | | | | | | | | | | | | | | Before: Total allocated: 209050523 bytes (2219202 objects) Total retained: 36580305 bytes (323462 objects) After: Total allocated: 209180253 bytes (2222455 objects) Total retained: 36515599 bytes (321850 objects) --- Modest saving of 1612 RVALUEs in the heap on Discourse boot The larger the route file the better the results. Saving will only be visible on Ruby 2.5 and up.
* correct the dedup codeSam2018-02-151-3/+3
|
* Revert "Revert "Merge pull request #31999 from SamSaffron/patch-1""Rafael Mendonça França2018-02-151-4/+11
| | | | This reverts commit f282f3758d31e8445d0854e2ae7a67f17cede3bc.
* Revert "Merge pull request #31999 from SamSaffron/patch-1"Rafael Mendonça França2018-02-151-11/+4
| | | | | | | This reverts commit 9f65d2a08bc80a94bbb2c0b6e00957c7059aed25, reversing changes made to 966843732a607864b077b72b2a17168d4e3548cc. This broken a lot of tests.
* PERF: dedupe scanned route fragmentsSam2018-02-151-4/+11
| | | | | | | | | | | | | | | | | | | | Per: https://bugs.ruby-lang.org/issues/13077 String @- will dedupe strings. This takes advantage of this by deduping route fragments that are full of duplication usually. For Discourse: Before: Total allocated: 207574305 bytes (2214916 objects) Total retained: 36470010 bytes (322194 objects) After Total allocated: 207556847 bytes (2214711 objects) Total retained: 36327973 bytes (318627 objects) <- object that GC can not collect So we save 3500 or so RVALUES this way, not the largest saving in the world, but worth it especially for large route files.
* Enable `Layout/LeadingCommentSpace` to not allow cosmetic changes in the futureRyuta Kamizono2017-12-141-10/+10
| | | | Follow up of #31432.
* removed unnecessary returnsShuhei Kitagawa2017-10-281-1/+1
|
* [Action Pack] require => require_relativeAkira Matsuda2017-10-219-16/+16
| | | | | This basically reverts e9fca7668b9eba82bcc832cb0061459703368397, d08da958b9ae17d4bbe4c9d7db497ece2450db5f, d1fe1dcf8ab1c0210a37c2a78c1ee52cf199a66d, and 68eaf7b4d5f2bb56d939f71c5ece2d61cf6680a3
* Update links to use https link instead of http [ci skip]Yoshiyuki Hirano2017-08-221-1/+1
|
* Path parameters should default to UTF8eileencodes2017-08-011-1/+6
| | | | | | | | | | | | | | | | | | | | This commit changes the behavior such the path_params now default to UTF8 just like regular parameters. This also changes the behavior such that if a path parameter contains invalid UTF8 it returns a 400 bad request. Previously the behavior was to encode the path params as binary but that's not the same as query params. So this commit makes path params behave the same as query params. It's important to test with a path that's encoded as binary because that's how paths are encoded from the socket. The test that was altered was changed to make the behavior for bad encoding the same as query params. We want to treat path params the same as query params. The params in the test are invalid UTF8 so they should return a bad request. Fixes #29669 *Eileen M. Uchitelle, Aaron Patterson, & Tsukuru Tanimichi*
* Use frozen string literal in actionpack/Kir Shatrov2017-07-2914-1/+29
|
* normalize_path used to be nil tolerantAkira Matsuda2017-07-121-0/+1
| | | | fixes a regression introduced at 8607c25ba7810573733d9b37d0015154ba059f5e
* [Action Pack] `rubocop -a --only Layout/EmptyLineAfterMagicComment`Koichi ITO2017-07-113-0/+3
|
* Prepare AP and AR to be frozen string friendlyKir Shatrov2017-07-062-3/+5
|
* Merge branch 'master' into require_relative_2017Xavier Noria2017-07-021-3/+3
|\
| * Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-0216-16/+0
| | | | | | | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
| * Merge pull request #29540 from kirs/rubocop-frozen-stringMatthew Draper2017-07-0216-0/+16
| |\ | | | | | | | | | Enforce frozen string in Rubocop
| | * Enforce frozen string in RubocopKir Shatrov2017-07-0116-0/+16
| | |
| * | Make ActionView frozen string literal friendly.Pat Allan2017-06-201-1/+1
| | | | | | | | | | | | Plus a couple of related ActionPack patches.
| * | Make ActionMailer frozen string literal friendly.Pat Allan2017-06-201-1/+1
| | |
| * | Make ActiveModel frozen string literal friendly.Pat Allan2017-06-201-1/+1
| |/ | | | | | | Includes two external changes because they're referenced within the ActiveModel test suite.
* / [Action Dispatch] require => require_relativeAkira Matsuda2017-07-019-16/+16
|/
* Merge pull request #29191 from ↵Kasper Timm Hansen2017-05-291-5/+5
|\ | | | | | | | | bogdanvlviv/pass_params_filename_lineno_to_class_eval Pass params __FILE__ and __LINE__ + 1 if class_eval with <<
| * Pass params __FILE__ and __LINE__ + 1 if class_eval with <<bogdanvlviv2017-05-291-5/+5
| |
* | Merge pull request #29176 from bogdanvlviv/define-path-with__dir__Matthew Draper2017-05-261-1/+1
|\ \ | |/ |/| Define path with __dir__
| * Define path with __dir__bogdanvlviv2017-05-231-1/+1
| | | | | | | | | | | | ".. with __dir__ we can restore order in the Universe." - by @fxn Related to 5b8738c2df003a96f0e490c43559747618d10f5f
* | Remove unused simulate methodeileencodes2017-05-221-8/+0
|/ | | | | | This method was only used in the Rails tests and not by other methods in the Rails simulator. Because it's a no-doc'd class it should be safe to remove without deprecation.
* Maintain original encoding from patheileencodes2017-05-121-0/+2
| | | | | | | | | When the path info is read from the socket it's encoded as ASCII 8BIT. The unescape method changes the encoding to UTF8 but it should maintain the encoding of the string that's passed in. This causes parameters to be force encoded to UTF8 when we don't actually know what the encoding of the parameter should be.
* Remove `:doc:` in `:nodoc:` class [ci skip]Ryuta Kamizono2017-05-011-2/+2
| | | | | The `:doc:` was added in bc478158 but originally `UriEncoder` is a `:nodoc:` class.
* Add periodJon Moss2017-04-301-1/+1
| | | | [ci skip]