开发者

URI::InvalidURIError (bad URI(is not URI?): ):

开发者 https://www.devze.com 2023-02-18 12:02 出处:网络
I am trying to implement an OAuth provider 开发者_如何学Cin 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

I am trying to implement an OAuth provider 开发者_如何学Cin 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.


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/


You can also use this alternative URI gem: https://github.com/sporkmonger/addressable

There is no such problems with it.

Very native, just add namespace in your code after installing the gem

Addressable::URI


try this:

safeurl = URI.encode(url.strip)
response = RestClient.get(safeurl)


I'm here because I faced an issue with the fastlane. It's been written with Ruby thus my answer can be helpful.

In my case, I had the environment variables http_proxy = XX.XX.XX.XX:XXXX and https_proxy = ... When I changed them to http_proxy = http://XX.XX.XX.XX:XXXX and https_proxy = https://... respectivle the issue has gone.

0

精彩评论

暂无评论...
验证码 换一张
取 消