lib/httpx/plugins/cookies/cookie.rb in httpx-0.15.4 vs lib/httpx/plugins/cookies/cookie.rb in httpx-0.16.0
- old
+ new
@@ -41,11 +41,11 @@
def <=>(other)
# RFC 6265 5.4
# Precedence: 1. longer path 2. older creation
(@name <=> other.name).nonzero? ||
(other.path.length <=> @path.length).nonzero? ||
- (@created_at <=> other.created_at).nonzero?
+ (@created_at <=> other.created_at).nonzero? || 0
end
class << self
def new(cookie, *args)
return cookie if cookie.is_a?(self)
@@ -105,10 +105,12 @@
end
end if attr_hash
@path ||= "/"
raise ArgumentError, "name must be specified" if @name.nil?
+
+ @name = @name.to_s
end
def expires
@expires || (@created_at && @max_age ? @created_at + @max_age : nil)
end
@@ -120,10 +122,10 @@
end
# Returns a string for use in the Cookie header, i.e. `name=value`
# or `name="value"`.
def cookie_value
- "#{@name}=#{Scanner.quote(@value)}"
+ "#{@name}=#{Scanner.quote(@value.to_s)}"
end
alias_method :to_s, :cookie_value
# Tests if it is OK to send this cookie to a given `uri`. A
# RuntimeError is raised if the cookie's domain is unknown.