Skip to content

Commit eee0b24

Browse files
Invalidate query parameters when replacing URLs.
Assisted-By: devx/cbdeae41-9308-4071-ad53-58cd92db2946
1 parent 8f9df47 commit eee0b24

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

lib/utopia/request.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ def ip
163163
# @parameter url [Protocol::URL::Absolute | Protocol::URL::Relative | String | Nil] The request URL.
164164
def url= url
165165
@url = Protocol::URL[url]
166+
@query_parameters = nil
166167
end
167168

168169
# Build a derived request with updated protocol fields.

test/utopia/request.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@
6161
}
6262
end
6363

64+
it "invalidates decoded query parameters when replacing the URL" do
65+
expect(request.query_parameters).to have_keys("q", "tag")
66+
67+
request.url = "/search?query=hello+world"
68+
69+
expect(request.query_parameters).to be == {"query" => "hello world"}
70+
end
71+
6472
it "distinguishes absent and empty query values" do
6573
request.url = "/search?absent&empty="
6674

0 commit comments

Comments
 (0)