Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Commits on May 11, 2014
  1. @pixeltrix

    Always use the provided port for protocol relative urls

    pixeltrix authored
    There may be situations where you need to tunnel SSL connections over
    port 80 so we shouldn't remove it if it has been explicitly provided.
Commits on Apr 20, 2014
  1. @pixeltrix

    Make URL escaping more consistent

    pixeltrix authored
    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.
Commits on Apr 11, 2014
  1. @pixeltrix

    Only make deeply nested routes shallow when parent is shallow

    pixeltrix authored
    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.
Commits on Mar 16, 2014
  1. @pixeltrix

    Use nested_scope? not shallow? to determine whether to copy options

    pixeltrix authored
    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.
Commits on Feb 9, 2014
  1. @pixeltrix

    Set the :shallow_path as each scope is generated

    pixeltrix authored
    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.
Commits on Jan 27, 2014
  1. @pixeltrix

    Clear filtered request attributes between requests in tests

    pixeltrix authored
    The request attributes filtered_parameters, filtered_env and filtered_path
    are memoized for performance reasons. However this can cause unusual
    behavior in tests where there are multiple calls to get, post, etc.
    
    Fixes #13803.
Commits on Jan 20, 2014
  1. @pixeltrix
Commits on Jan 5, 2014
  1. @pixeltrix
  2. @pixeltrix

    Unique the segment keys array for non-optimized url helpers

    pixeltrix authored
    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
  3. @pixeltrix

    Show full route constraints in error message

    pixeltrix authored
    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
  4. @pixeltrix

    Use a custom route vistor for optimized route generation

    pixeltrix authored
    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
Commits on Jan 1, 2014
  1. @pixeltrix

    Allow engine root relative redirects using an empty string.

    pixeltrix authored
    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
Commits on Dec 29, 2013
  1. @pixeltrix

    Fix Encoding::CompatibilityError when public path is UTF-8

    pixeltrix authored
    In #5337 we forced the path encoding to ASCII-8BIT to prevent static
    file handling from blowing up before an application has had chance to
    deal with possibly invalid urls. However this has a negative side
    effect of making it an incompatible encoding if the application's
    public path has UTF-8 characters in it.
    
    To work around the problem we check to see if the path has a valid
    encoding once it has been unescaped. If it is not valid then we can
    return early since it will not match any file anyway.
    
    Fixes #13518
Commits on Dec 2, 2013
  1. @pixeltrix

    Try to escape each part of a path redirect route correctly

    pixeltrix authored
    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.
Commits on Oct 10, 2013
  1. @pixeltrix

    Respect `SCRIPT_NAME` when using `redirect` with a relative path

    pixeltrix authored
    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
Commits on Sep 30, 2013
  1. @pixeltrix

    Add changlog entry for #10844

    pixeltrix authored
Commits on Jul 25, 2013
  1. @pixeltrix

    Allow overriding of all headers from passed environment hash

    pixeltrix authored
    Allow REMOTE_ADDR, HTTP_HOST and HTTP_USER_AGENT to be overridden from
    the environment passed into `ActionDispatch::TestRequest.new`.
    
    Fixes #11590
Commits on Jul 21, 2013
  1. @pixeltrix

    Clear named routes when routes.rb is reloaded

    pixeltrix authored
    Fix an issue where Journey was failing to clear the named routes hash when the
    routes were reloaded and since it doesn't overwrite existing routes then if a
    route changed but wasn't renamed it kept the old definition. This was being
    masked by the optimised url helpers so it only became apparent when passing an
    options hash to the url helper.
Commits on Jul 16, 2013
  1. @pixeltrix

    Skip Rack applications and redirects when generating urls

    pixeltrix authored
    When generating an unnamed url (i.e. using `url_for` with an options
    hash) we should skip anything other than standard Rails routes otherwise
    it will match the first mounted application or redirect and generate a
    url with query parameters rather than raising an error if the options
    hash doesn't match any defined routes.
    
    Fixes #8018
Commits on Jun 25, 2013
  1. @pixeltrix

    Fix shorthand routes where controller and action are in the scope

    pixeltrix authored
    Merge `:action` from routing scope and assign endpoint if both `:controller`
    and `:action` are present. The endpoint assignment only occurs if there is
    no `:to` present in the options hash so should only affect routes using the
    shorthand syntax (i.e. endpoint is inferred from the the path).
    
    Fixes #9856
Commits on Apr 25, 2013
  1. @pixeltrix

    Add support for extra options to `force_ssl`

    pixeltrix authored
    This commit adds support for passing additional url options along
    with a :status option and any of the flash-related options to
    `redirect_to` (i.e. :flash, :alert & :notice).
    
    Closes #7570.
  2. @pixeltrix

    Use `request.fullpath` to build redirect url in `force_ssl`

    pixeltrix authored
    The `force_ssl` command now builds the redirect url from `request.fullpath`.
    This ensures that the format is maintained and it doesn't redirect to a route
    that has the same parameters but is defined earlier in `routes.rb`. Also any
    optional segments are maintained.
    
    Fixes #7528.
    Fixes #9061.
    Fixes #10305.
Commits on Apr 18, 2013
  1. @pixeltrix
Commits on Feb 21, 2013
  1. @pixeltrix

    Merge pull request #9361 from senny/improved_match_shorthand_syntax

    pixeltrix authored
    determine the match shorthand target early.
Commits on Jan 15, 2013
  1. @pixeltrix

    Change the behavior of route defaults

    pixeltrix authored
    This commit changes route defaults so that explicit defaults are no
    longer required where the key is not part of the path. For example:
    
      resources :posts, bucket_type: 'posts'
    
    will be required whenever constructing the url from a hash such as a
    functional test or using url_for directly. However using the explicit
    form alters the behavior so it's not required:
    
      resources :projects, defaults: { bucket_type: 'projects' }
    
    This changes existing behavior slightly in that any routes which
    only differ in their defaults will match the first route rather
    than the closest match.
    
    Closes #8814
  2. @pixeltrix

    Add support for other types of routing constraints

    pixeltrix authored
    This now allows the use of arrays like this:
    
      get '/foo/:action', to: 'foo', constraints: { subdomain: %w[www admin] }
    
    or constraints where the request method returns an Fixnum like this:
    
      get '/foo', to: 'foo#index', constraints: { port: 8080 }
    
    Note that this only applies to constraints on the request - path
    constraints still need to be specified as Regexps as the various
    constraints are compiled into a single Regexp.
  3. @pixeltrix
Commits on Dec 19, 2012
  1. @pixeltrix

    Integrate Journey into Action Dispatch

    pixeltrix authored
    Move the Journey code underneath the ActionDispatch namespace so
    that we don't pollute the global namespace with names that may
    be used for models.
    
    Fixes rails/journey#49.
Commits on Dec 14, 2012
  1. @pixeltrix

    Clear url helper methods when routes are reloaded

    pixeltrix authored
    Remove all the old url helper methods when clear! is called on the
    route set because it's possible that some routes have been removed.
  2. @pixeltrix

    Revert "Clear url helpers when reloading routes"

    pixeltrix authored
    This doesn't actually remove old url helper methods as they are
    defined in a different module.
    
    This reverts commit 96bcef9.
    
    Conflicts:
    	actionpack/CHANGELOG.md
Commits on Dec 7, 2012
  1. @pixeltrix
Commits on Dec 6, 2012
  1. @pixeltrix

    Invert precedence of content in ActionDispatch::Static

    pixeltrix authored
    This commit inverts the precedence in ActionDispatch::Static so that
    dynamic content will be served before static content. This is so that
    precompiled assets do not inadvertently get included when running in
    development mode - it should have no effect in production where static
    files are usually handled by the web server.
    
    Closes #6421
Commits on Aug 29, 2012
  1. @pixeltrix

    Merge pull request #7230 from schneems/schneems/expose_required_keys

    pixeltrix authored
    Add Missing Keys from Journey on Failed URL Format
Commits on Aug 4, 2012
  1. @pixeltrix

    Revert "Refactor passing url options via array for polymorphic_url"

    pixeltrix authored
    Passing options as the last value in an array doesn't work with form_for.
    This reverts commit 6be564c.
  2. @pixeltrix

    Refactor passing url options via array for polymorphic_url

    pixeltrix authored
    Rather than keep the url options in record_or_hash_or_array, extract it
    and reverse merge with options as it may contain important private keys
    like `:routing_type`.
    
    Closes #7259
Something went wrong with that request. Please try again.