Skip to content

Commit

Permalink
use Rack::Util for parsing and building URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
jbennett committed Jan 1, 2025
1 parent a2d55df commit 40b8f47
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/hotwire_combobox/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ def hw_first_page?

def hw_uri_with_params(url_or_path, **params)
URI.parse(url_or_path).tap do |url_or_path|
query = Rack::Utils.parse_query(url_or_path.query || "").merge(params.compact_blank.stringify_keys)
url_or_path.query = URI.encode_www_form query
query = Rack::Utils.parse_nested_query(url_or_path.query || "").merge(params.compact_blank.stringify_keys)
url_or_path.query = Rack::Utils.build_nested_query query
end.to_s
rescue URI::InvalidURIError
url_or_path
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/hotwire_combobox/helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class HotwireCombobox::HelperTest < ApplicationViewTestCase

html = hw_paginated_combobox_options [], next_page: 2

assert_attrs html, tag_name: "turbo-frame", src: "/foo?ary=1&ary=2&page=2&format=turbo_stream"
assert_attrs CGI.unescape(html), tag_name: "turbo-frame", src: "/foo?ary[]=1&ary[]=2&page=2&format=turbo_stream"
end

test "single repeating character values" do
Expand Down

0 comments on commit 40b8f47

Please sign in to comment.