If you create a URL with query parameters in a string URL such as https: // xxxx, the query parameters need to be converted to a special form.
You need to execute encodeURIComponent in JavaScript.
This makes + to% 2B and & to% 26.
Ruby uses CGI.escape.
require 'cgi'
CGI.escape('+ &') # => "%2B+%26"
Try constructing the URL using CGI.escape.
There are many things that can be improved, such as using hashes, but here is a simple pattern.
"https://samole.com?key={CGI.escape(value)}"
Only value is escaped, thinking that it is unlikely to use special characters for key.
If you also want to escape key,
You can refer to https://github.com/rails/rails/blob/3-0-stable/activesupport/lib/active_support/core_ext/object/to_query.rb.
Recommended Posts