Removing a query string from a URL in Ruby can be done as follows:
url.split('?')[0]
Where url is the full URL, including the query string (e.g. url = http://www.domain.extension/folder?schnoo=schnok&foo=bar).
Is there a faster way to do this, i.e. without using split, but instead of using Rails?
edit: The goal is to redirect from http://www.domain.extension/folder?schnoo=schnok&foo=barto http://www.domain.extension/folder.
EDIT: I used:
url = 'http://www.domain.extension/folder?schnoo=schnok&foo=bar'
parsed_url = URI.parse(url)
new_url = parsed_url.scheme+"://"+parsed_url.host+parsed_url.path
source
share