Mocking a web request with the excellent WebMock library lead to the following error:
This error occured whenever a domain contained
_, e.g. an underscore character.
I was dealing with a mock URL anyway, I was able to replace the underscore with a hyphen
At the end of this rubyforums discussion you can find a relatively simple solution which solves this problem for cases where you have no control over the domain name:
The aforementioned discussion has some interesting insights, on which I will give a brief summary here:
RFC 1738, section 3.1. explains the host scheme:
In short, URI won’t parse domain names with underscores. Those are officially invalid, even though they are used sometimes. Some people don’t have the luxury to just change the URI since some domain names contain an underscore and need to be accessed.
If you have no control over the domain, you can either