Skip to content

Commit

Permalink
Make sure #normalized_path does not depend on modifying @path.
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Apr 11, 2011
1 parent 93a4588 commit 79c5640
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/addressable/uri.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1266,14 +1266,14 @@ def path
# @return [String] The path component, normalized.
def normalized_path
@normalized_path ||= (begin
if self.scheme == nil && self.path != nil && !self.path.empty? &&
self.path =~ NORMPATH
path = self.path
if self.scheme == nil && path != nil && !self.path.empty? && path =~ NORMPATH
# Relative paths with colons in the first segment are ambiguous.
self.path.sub(":", "%2F")
path.sub!(":", "%2F")
end
# String#split(delimeter, -1) uses the more strict splitting behavior
# found by default in Python.
result = (self.path.strip.split(SLASH, -1).map do |segment|
result = (path.strip.split(SLASH, -1).map do |segment|
Addressable::URI.normalize_component(
segment,
Addressable::URI::CharacterClasses::PCHAR
Expand Down

0 comments on commit 79c5640

Please sign in to comment.