Skip to content

Commit

Permalink
Update helper URI module
Browse files Browse the repository at this point in the history
Use addressable gem over default URI module. This gem handles non
RFC2396 compliant URLs. Required to fix #8211 in WDTK theme.
  • Loading branch information
gbp committed Apr 22, 2024
1 parent e855013 commit 8e8701f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/helpers/link_to_helper.rb
Expand Up @@ -349,7 +349,7 @@ def dom_id(record, prefix = nil)
end

def add_query_params_to_url(url, new_params)
uri = URI.parse(url)
uri = Addressable::URI.parse(url)
uri.query = Rack::Utils.parse_nested_query(uri.query).
with_indifferent_access.
merge(new_params).
Expand Down
6 changes: 6 additions & 0 deletions spec/helpers/link_to_helper_spec.rb
Expand Up @@ -370,5 +370,11 @@
new_params = {}
expect(add_query_params_to_url(url, new_params)).to eq url
end

it 'does not error when URL is not RFC2396 compliant' do
url = 'http://example.com/a url with spaces'
new_params = { foo: 1 }
expect { add_query_params_to_url(url, new_params) }.to_not raise_error
end
end
end

0 comments on commit 8e8701f

Please sign in to comment.