Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
894 views
in Technique[技术] by (71.8m points)

ruby on rails 3 - URI::InvalidURIError (bad URI(is not URI?): ):

I am trying to implement an OAuth provider in Rails 3. When I try to authorize a client app I get this error. I am using the RESTful auth plugin and pelles OAuth-plugin. When I was testing via the Rails console and getting this error I thought that I simply needed to encode the URLs but I get the same error when testing in browser so I am not sure what is wrong.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I got into trouble with URI.split (returning this error), I don't know if this helps you, but I will post here some warnings for also someone else having this error:

  1. Check your url is not nil, and it's a valid one.
  2. Do URI.encode(url) before URI.parse (to avoid special characters)
  3. Do strip to the string you pass to URI.parse (to avoid leading and trailing whitespaces).

All in one:

uri = URI.parse(URI.encode(url.strip))

Related resource: http://www.practicalguile.com/2007/09/15/raising-uriinvalidurierror-from-a-perfectly-valid-uri/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...