Commit Graph

59 Commits

Author SHA1 Message Date
akihiro17
388124e411 Remove TestRouter#add_routes
Now, we use the mapper to build the routing table

related to 703275ba70
2015-09-29 13:43:11 +09:00
Akira Matsuda
dcecbb4234 File encoding is defaulted to utf-8 in Ruby >= 2.1 2015-09-18 17:05:05 +09:00
Aaron Patterson
4d9475bef9 symbols will always be constructed with strings. 💣 2015-08-18 15:20:19 -07:00
Aaron Patterson
c42db41f54 routes are always constructed with a hash for the conditions 2015-08-17 16:30:53 -07:00
Aaron Patterson
1ce74b009f introduce an alternate constructor for Route objects
I want to change the real constructor to take a particular parameter for
matching the request method
2015-08-17 16:08:39 -07:00
Aaron Patterson
e9777ef62e default pattern to use a joined string
The string we create is almost always the same, so rather than joining
all the time, lets join once, then reuse that string everywhere.
2015-08-17 13:51:38 -07:00
Aaron Patterson
703275ba70 use the mapper to build the routing table
We should build the routes using the user facing API which is `Mapper`.
This frees up the library internals to change as we see fit. IOW we
shouldn't be testing internals.
2015-08-15 14:32:04 -07:00
Aaron Patterson
a293812bff only keep one hash of named routes
The outer router object already keeps a hash of named routes, so we
should just use that.
2015-08-14 18:06:48 -07:00
Aaron Patterson
4bdd92d9fd rm add_route2
refactor the tests with a backwards compatible method call so we can rm
add_route2 from the journey router
2015-08-14 16:25:03 -07:00
Aaron Patterson
7fa6600b52 use predicate methods instead of hard coding verb strings
also change the feeler to subclass AD::Request so that it has all the
methods that Request has
2015-08-14 10:39:33 -07:00
Aaron Patterson
947ebe9a6d remove Strexp
This was a useless object.  We can just directly construct a
Path::Pattern object without a Strexp object.
2015-08-13 15:42:46 -07:00
Aaron Patterson
4868692687 pass anchor directly to Pattern
the caller already has it, there is no reason to pack it in to an object
and just throw that object away.
2015-08-13 15:16:25 -07:00
Arthur Neves
ffba8f79a2
Revert "Merge pull request #20584 from arthurnn/fix_url"
This reverts commit 0b3397872582f2cf1bc6960960a6393f477c55e6, reversing
changes made to 56d52e3749180e6c1dcf7166adbad967470aa78b.

As pointed out on the PR, this will hide development mistakes too, which
is not ideal.
2015-06-17 20:17:44 +02:00
Arthur Neves
e23b314945
Catch InvalidURIError on bad paths on redirect.
Handle URI::InvalidURIError errors on the redirect route method, so it
wont raise a 500 if a bad path is given.
2015-06-16 23:27:49 +02:00
Aaron Patterson
8037d7eacd extract required_defaults from the conditions hash before constructing the route
this way we can remove the strange "respond_to?" conditional in the
`matches?` loop
2015-06-08 17:18:32 -07:00
Rafael Mendonça França
d4cfd54308 Prefer assert_not over refute 2015-05-18 19:33:25 -03:00
Valentine Valyaeff
bad30ed46c ActionDispatch::Journey::Routes#empty? test cases 2015-05-19 01:21:20 +03:00
Prem Sichanugrist
7cb9e20c6c Silence ambiguous first argument warning
This silences:

    actionpack/test/journey/route_test.rb:33: warning: ambiguous first
    argument; put parentheses or a space even after `/' operator
2015-05-04 10:15:50 -04:00
Arthur Nogueira Neves
86929c00c0 Merge pull request #18392 from brainopia/fix_route_requirements
Correct route requirements by overriding defaultls
2015-04-27 09:15:22 -04:00
Yang Bo
a77de09812 sort_by instead of sort
it is avoid sort errot within different and mixed keys.
used `sort_by` + `block` to list parameter by keys.
keep minimum changes
2015-04-08 22:18:56 +08:00
Aaron Patterson
12f2fc56aa Merge pull request #15806 from tgxworld/partition_routes_during_setup
Partition routes during setup.
2015-03-02 15:02:14 -08:00
Zoltan Kiss
f5b192837a Remove unneeded comment. [ci skip] 2015-03-02 11:03:33 -06:00
Guo Xiang Tan
89edfbd3a4 Partition routes during setup.
Partitioning of all the routes is currently being done during the
first request. Since there is no need to clear the cache for
`partitioned_routes` when adding a new route. We can move the
partitioning of the routes during setup time.
2015-02-26 12:18:20 +08:00
Vipul A M
6eced6a1fe Removed magic comments # encoding: utf-8 , since its default from ruby 2.0 onwards. 2015-02-03 20:51:40 +05:30
brainopia
f9e2496872 Correct route requirements by overriding defaultls (fixes #18373) 2015-01-08 02:53:57 +03:00
Konstantin Haase
0d690d75fb make OR in journey patterns compile to a valid regular expression 2014-11-29 01:26:10 +01:00
Godfrey Chan
938d130c62 Fix cases where the wrong name is passed to Formatter#generate
These are currently working "by accident" because `match_route` does not check
that the name is valid.
2014-11-23 01:08:53 -08:00
Accessd
2224bf7992 fix url generation error message 2014-10-21 12:10:48 +04:00
Nicolas Cavigneaux
3041bb2a94 Improve Journey compliance to RFC 3986
The scanner in Journey fails to recognize routes that use literals
from the sub-delims section of RFC 3986.

This commit enhance the compatibility of Journey with the RFC by
adding support of authorized delimiters to the scanner.

Fix #17212
2014-10-14 16:42:50 +02:00
Guo Xiang Tan
9212042631 Improve router test.
We should assert that routes will not be recognized if the verbs do
not match.
2014-08-21 16:35:39 +08:00
Guo Xiang Tan
d3eb92d95a Avoid duplicating routes for HEAD requests.
Follow up to rails#15321

Instead of duplicating the routes, we will first match the HEAD request to
HEAD routes. If no match is found, we will then map the HEAD request to
GET routes.
2014-08-21 16:35:39 +08:00
Karl Entwistle
8a29713134 Force encoding of US-ASCII to UTF-8 in unescape_uri.
Because URI paths may contain non US-ASCII characters we need to force
the encoding of any unescaped URIs to UTF-8 if they are US-ASCII.
This essentially replicates the functionality of the monkey patch to
URI.parser.unescape in active_support/core_ext/uri.rb.

Fixes #16104.
2014-07-10 10:02:11 +01:00
Kuldeep Aggarwal
fca73eeb87 remove warnings
warning: assigned but unused variable - scope_called, path and strexp
2014-06-12 00:27:58 +05:30
Aaron Patterson
da2cf937aa no more is_a checks on instantiation 2014-05-29 15:45:42 -07:00
Aaron Patterson
bb207ea7b6 Path::Pattern is instantiated internally, so make the contructor require a strexp object 2014-05-29 15:44:54 -07:00
Aaron Patterson
5682596db7 Strexp#names is only used in a test, so rm 2014-05-29 15:31:45 -07:00
Aaron Patterson
15ffbedf3b add an alternate constructor to Strexp that takes a string 2014-05-29 15:23:30 -07:00
Guo Xiang Tan
b1bc553385 Remove TODO. 2014-05-28 20:06:08 -07:00
Aaron Patterson
b18f22d15c pass the request object to the application 2014-05-25 14:26:48 -07:00
Aaron Patterson
633589c140 push is_a?(Dispatcher) check in to one place 2014-05-24 19:03:12 -07:00
Aaron Patterson
6d48d97947 glob_param is never used, so rm
this also changes the constructor.  We don't need to pass more options
than "defaults" (whatever defaults are, ugh. probably another hash of
stupid stuff).
2014-05-23 15:25:46 -07:00
Aaron Patterson
0f5e3a9f6b decouple the router object from the request class 2014-05-23 10:57:25 -07:00
Aaron Patterson
6fd8346400 pass the correct custom request to the recognize method 2014-05-23 10:57:25 -07:00
Aaron Patterson
6ed5b01f97 switch to the serve method so we can remove the request class (eventually) 2014-05-23 10:57:25 -07:00
Aaron Patterson
890e0a97fb remove NullRequest and just always pass a request class 2014-05-23 10:09:24 -07:00
Aaron Patterson
a6e94547e8 use the request object since we have it
stop hardcoding hash keys and use the accessors provided on the request
object.
2014-05-23 09:56:33 -07:00
Aaron Patterson
dd1f23df7b middle variable is never used, so rm 2014-05-21 16:12:49 -07:00
Aaron Patterson
089d9baa33 we don't use this parameter for anything, so rm 2014-05-20 16:06:59 -07:00
Andrew White
5460591f02 Make URL escaping more consistent
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.
2014-04-20 10:11:38 +01:00
edogawaconan
e2ef83f838 Always escape string passed to url helper.
Makes it clear that anything passed with the helper must not be percent encoded.

Fixes previous behavior which tricks people into believing passing
non-percent-encoded will generate a proper percent-encoded path while in
reality it doesn't ('%' isn't escaped).

The intention is nice but the heuristic is broken.
2014-04-20 10:11:37 +01:00