lib/httpx/plugins/cookies/jar.rb in httpx-0.15.1 vs lib/httpx/plugins/cookies/jar.rb in httpx-0.15.2
- old
+ new
@@ -41,9 +41,13 @@
def add(cookie, path = nil)
c = cookie.dup
c.path = path if path && c.path == "/"
+ # If the user agent receives a new cookie with the same cookie-name, domain-value, and path-value
+ # as a cookie that it has already stored, the existing cookie is evicted and replaced with the new cookie.
+ @cookies.delete_if { |ck| ck.name == c.name && ck.domain == c.domain && ck.path == c.path }
+
@cookies << c
end
def [](uri)
each(uri).sort