Answer the question
In order to leave comments, you need to log in
How to encode only unencoded URLs?
URLs from different sources can be in different forms: somewhere they are already encoded, somewhere they still need to be encoded.
I use
def urlencode(url)
url = begin
url = URI(url)
url
rescue URI::InvalidURIError
URI.encode(url)
end
end
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question