Method: Addressable::URI#path=

Defined in:
lib/vendor/addressable/lib/addressable/uri.rb

#path=(new_path) ⇒ Object

Sets the path component for this URI.

Parameters:

Raises:

  • (TypeError)


1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
# File 'lib/vendor/addressable/lib/addressable/uri.rb', line 1136

def path=(new_path)
  # Check for frozenness
  raise TypeError, "Can't modify frozen URI." if self.frozen?

  if new_path && !new_path.respond_to?(:to_str)
    raise TypeError, "Can't convert #{new_path.class} into String."
  end
  @path = (new_path || "").to_str
  if @path != "" && @path[0..0] != "/" && host != nil
    @path = "/#{@path}"
  end

  # Reset dependant values
  @normalized_path = nil
  @uri_string = nil
end