Module Rack::Mount::Utils
In: lib/rack/mount/utils.rb

Private utility methods used throughout Rack::Mount.

Methods

Constants

RESERVED_PCHAR = ':@&=+$,;%'
SAFE_PCHAR = "#{URI::REGEXP::PATTERN::UNRESERVED}#{RESERVED_PCHAR}"
UNSAFE_PCHAR = Regexp.new("[^#{SAFE_PCHAR}]", false).freeze
UNSAFE_PCHAR = Regexp.new("[^#{SAFE_PCHAR}]", false, 'N').freeze
Parser = URI.const_defined?(:Parser) ? URI::Parser.new : URI

Public Instance methods

Normalizes URI path.

Strips off trailing slash and ensures there is a leading slash.

  normalize_path("/foo")  # => "/foo"
  normalize_path("/foo/") # => "/foo"
  normalize_path("foo")   # => "/foo"
  normalize_path("")      # => "/"

Removes trailing nils from array.

  pop_trailing_blanks!([1, 2, 3])           # => [1, 2, 3]
  pop_trailing_blanks!([1, 2, 3, nil, ""])  # => [1, 2, 3]
  pop_trailing_blanks!([nil])               # => []
  pop_trailing_blanks!([""])                # => []

Determines whether the regexp must match the entire string.

  regexp_anchored?(/^foo$/) # => true
  regexp_anchored?(/foo/)   # => false
  regexp_anchored?(/^foo/)  # => false
  regexp_anchored?(/foo$/)  # => false

[Validate]