method

normalize_path

v1_9_3_125 - Show latest stable - Class: WEBrick::HTTPUtils
normalize_path(path)
private

No documentation available.

# File lib/webrick/httputils.rb, line 21
    def normalize_path(path)
      raise "abnormal path `#{path}'" if path[0] != //
      ret = path.dup

      ret.gsub!(%{/+}, '/')                    # //      => /
      while ret.sub!(%/\.(?:/|\Z)', '/'); end  # /.      => /
      while ret.sub!(%/(?!\.\./)[^/]+/\.\.(?:/|\Z)', '/'); end # /foo/.. => /foo

      raise "abnormal path `#{path}'" if %{/\.\.(/|\Z)} =~ ret
      ret
    end