| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
1. Escape '%' characters in URLs - only unescaped data
should be passed to URL helpers
2. Add an `escape_segment` helper to `Router::Utils`
that escapes '/' characters
3. Use `escape_segment` rather than `escape_fragment`
in optimized URL generation
4. Use `escape_segment` rather than `escape_path`
in URL generation
For point 4 there are two exceptions. Firstly, when a route uses wildcard
segments (e.g. *foo) then we use `escape_path` as the value may contain '/'
characters. This means that wildcard routes can't be optimized. Secondly,
if a `:controller` segment is used in the path then this uses `escape_path`
as the controller may be namespaced.
Fixes #14629, #14636 and #14070.
|
|
|
|
|
|
|
|
|
|
| |
Since `:shallow` may be set at any point in the resource nesting we should
only make the new and collection routes shallow when the parent is shallow.
This is a bit of a hack but until the mapper is refactored to an object graph
instead of a hash of merged values it's the best we can do.
Fixes #14684.
|
|\ |
|
| |
| |
| |
| |
| |
| |
| | |
THe match documentation doesn't mention any requirement of the
parameter name requirement for matches. However, including a
bare glob character without a variable assignment causes a
parse error.
|
| |
| |
| |
| |
| |
| |
| |
| | |
The method `shallow?` returns false if the parent resource is a singleton so
we need to check if we're not inside a nested scope before copying the :path
and :as options to their shallow equivalents.
Fixes #14388.
|
| |
| |
| |
| |
| |
| | |
If the options :shallow_prefix and :shallow_path are not set in the
scope options then copy them from the normal :as and :path options
if they are set.
|
| |
| |
| |
| |
| |
| |
| | |
If a developer has specified either :path or :as in the options hash then
these should be used as the defaults for :shallow_path and :shallow_prefix.
Fixes #14241.
|
| |
| |
| |
| |
| |
| |
| |
| | |
By tracking the depth of resource nesting we can push the need for nested
shallow scoping to only those routes that are nested more than one deep.
This allows us to keep the fix for #12498 and fix the regression in #14224.
Fixes #14224.
|
|/
|
|
|
|
|
|
| |
Originally with_scope_level was exclusively for managing scope levels with
resources, however it is now used for other things so it makes more sense
to move the responsibility for setting the :scope_level_resource to the
resource_scope method. This eliminates repeatedly setting it to the same
resource as each resource method scope is evaluated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If we set :shallow_path when shallow is called it can result in incorrect
paths if the resource is inside a namespace because namespace itself sets
the :shallow_path option to the namespace path.
We fix this by removing the :shallow_path option from shallow as that should
only be turning shallow routes on and not otherwise affecting the scope.
To do this we need to treat the :shallow option to resources differently to
other scope options and move it to before the nested block is called.
This change also has the positive side effect of making the behavior of the
:shallow option consistent with the shallow method.
Fixes #12498.
|
|
|
|
| |
Fixes #13824
|
|
|
|
|
|
| |
fixes rails/rails#13810
Squash
|
| |
|
| |
|
|
|
|
| |
Fixes #12777
|
|
|
|
|
|
|
|
|
|
| |
In Rails 3.2 you only needed pass an argument for dynamic segment once so
unique the segment keys array to match the number of args. Since the number
of args is less than required parts the non-optimized code path is selected.
This means to benefit from optimized url generation the arg needs to be
specified as many times as it appears in the path.
Fixes #12808
|
|
|
|
|
|
|
|
| |
When an optimized helper fails to generate, show the full route constraints
in the error message. Previously it would only show the contraints that were
required as part of the path.
Fixes #13592
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Using a Regexp to replace dynamic segments in a path string is fraught
with difficulty and can lead to odd edge cases like #13349. Since we
already have a parsed representation of the path it makes sense to use
that to generate an array of segments that can be used to build an
optimized route's path quickly.
Tests on a simple route (e.g. /posts/:id) show a speedup of 35%:
https://gist.github.com/pixeltrix/8261932
Calculating -------------------------------------
Current Helper: 5274 i/100ms
New Helper: 8050 i/100ms
-------------------------------------------------
Current Helper: 79263.6 (±3.7%) i/s - 395550 in 4.997252s
New Helper: 153464.5 (±4.9%) i/s - 772800 in 5.047834s
Tests on a more complex route show even an greater performance boost:
https://gist.github.com/pixeltrix/8261957
Calculating -------------------------------------
Current Helper: 2367 i/100ms
New Helper: 5382 i/100ms
-------------------------------------------------
Current Helper: 29506.0 (±3.2%) i/s - 149121 in 5.059294s
New Helper: 78815.5 (±4.1%) i/s - 398268 in 5.062161s
It also has the added benefit of fixing the edge cases described above.
Fixes #13349
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Example:
# application routes.rb
mount BlogEngine => '/blog'
# engine routes.rb
get '/welcome' => redirect('')
This now redirects to the path `/blog`, whereas before it would redirect
to the application root path. In the case of a path redirect or a custom
redirect if the path returned contains a host then the path is treated as
absolute. Similarly for option redirects, if the options hash returned
contains a `:host` or `:domain` key then the path is treated as absolute.
Fixes #7977
|
| |
|
|
|
|
| |
Closes #9625
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When a route is mounted inside a resources block, it's automatically
prefixed, so a following code:
resources :users do
mount Blog::Engine => '/blog'
end
will generate a user_blog path helper.
In order to access engine helpers, we also use "mounted_helpers", a list
of helpers associated with each mounted engine, so a path to blog's post
can be generated using user_blog.post_path(user, post).
The problem I'm fixing here is that mount used a raw :as option, without
taking nestings into account. As a result, blog was added to a route set
as a `user_blog`, but helper was generated for just `blog`.
This commit applies the proper logic for defining a helper for a mounted
engine nested in resources or resource block.
(closes #8533)
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
A path redirect may contain any and all parts of a url which have different
escaping rules for each part. This commit tries to escape each part correctly
by splitting the string into three chunks - path (which may also include a host),
query and fragment; then it applies the correct escape pattern to each part.
Whilst using `URI.parse` would be better, unfortunately the possible presence
of %{name} parameters in the path redirect string prevents us from using it so
we have to use a regular expression instead.
Fixes #13110.
|
|\
| |
| |
| |
| |
| | |
Conflicts:
activesupport/lib/active_support/core_ext/hash/deep_merge.rb
activesupport/lib/active_support/core_ext/hash/keys.rb
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
According to our guideline, we leave 1 space between `#` and `=>`, so we
want `# =>` instead of `#=>`.
Thanks to @fxn for the suggestion.
[ci skip]
|
| |
| |
| |
| | |
This commit fixes formatting issue for `rake routes` task, when a section is shorter than a header.
|
| |
| |
| |
| | |
Only set the value once after it's calculated.
|
| | |
|
| | |
|
| | |
|
| | |
|
|/
|
|
|
|
|
|
|
|
| |
These errors occur when, there routes are wrongly defined.
example, the following line would cause a missing :action error
root "welcomeindex"
Mostly beginners are expected to hit these errors, so lets improve the error message a bit to make their learning experience bit better.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Example:
# application routes.rb
mount BlogEngine => '/blog'
# engine routes.rb
get '/admin' => redirect('admin/dashboard')
This now redirects to the path `/blog/admin/dashboard`, whereas before it
would've generated an invalid url because there would be no slash between
the host name and the path. It also allows redirects to work where the
application is deployed to a subdirectory of a website.
Fixes #7977
|
|\ |
|
| |
| |
| |
| |
| |
| | |
The documentation is showing the link_to method as just returning
the contents of the url_for method. It should be returning an
"<a>" tag with the correct href set.
|
|\ \
| | |
| | |
| | | |
Adding documentation and tests to ``polymorphic_url`` and ``link_to``
|
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
concerning the options that it inherits from +url_for+. The way that
+polymorhpic_url+ is built allows it to have options
like +:anchor+, +:script_name+, etc. but this is currently not
documented.
|
|\ \ \
| | | |
| | | | |
Fix typos: the indefinite articles(a -> an).
|
| | | | |
|
| |_|/
|/| |
| | |
| | |
| | |
| | |
| | |
| | | |
This reverts commit ab5cd54b7e791f8419f689d1bef5394890268a6f, reversing
changes made to cdc10c898d4865302740340eedec4f5f4ca76565.
Reason: This way of defining root path is still supported. See
https://github.com/rails/rails/blob/d262773ab7f0aae5de2d354ac2eca168e95b653d/actionpack/test/controller/routing_test.rb#L450-457
|
|\ \ \ |
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
The documentation in this section is referring to a profile,
so the resource that's created should probably also be a
profile of some sort.
|
| |/ /
| | |
| | |
| | |
| | |
| | | |
The docs refference a blacklist, but really what's being described
is a whitelist. Anything that matches the constraint gets through to
the path.
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | | |
Reference:
Bloody mess internals
http://gusiev.com/slides/rails_contribution/static/#40
|