-2

So I have this string URL for an HTTP request

http://locahost:3000/stuff?owner=foo bar+type=video game

I need to pass this as part of an HTTP get request to another ruby service. How do I encode this URL, i.e. take off the spaces and special characters and come up with the right request URL? Is there a gem to handle that. I know this could probably be done with some kind of regex, but I was hoping to find a standard gem that could do this.

1

1 Answer 1

3
require 'uri'
uri_string = URI::encode("http://localhost:3000/stuff?owner=foo bar+type=video game")

Not sure how searching for "ruby url encode" or parsing etc. didn't find that for you.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.