static public Method

Routing.normalize_paths(paths)

There's no documentation for this item.

Source Code

# File action_controller/routing.rb, line 266
def normalize_paths(paths)
  # do the hokey-pokey of path normalization...
  paths = paths.collect do |path|
    path = path.
      gsub("//", "/").           # replace double / chars with a single
      gsub("\\\\", "\\").        # replace double \ chars with a single
      gsub(%r{(.)[\\/]$}, '\1')  # drop final / or \ if path ends with it

    # eliminate .. paths where possible
    re = %r{\w+[/\\]\.\.[/\\]}
    path.gsub!(%r{\w+[/\\]\.\.[/\\]}, "") while path.match(re)
    path
  end

  # start with longest path, first
  paths = paths.uniq.sort_by { |path| - path.length }
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.