title: How to parse URL with forward slash in userinfo part
body: <p>I have a URL of this format:</p>
  
  <pre><code>https://clientjiberish:clientsecretjiberish@api.example.com/users?username=tralala
  </code></pre>
  
  <p>when I do:</p>
  
  <pre><code>url = 'https://clientjiberish:clientsecretjiberish@api.example.com/users?username=tralala'
  uri = URI(url)
  </code></pre>
  
  <p>I get all that I need.</p>
  
  <pre><code>uri.host =&gt; "api.example.com"
  uri.userinfo =&gt; "clientjiberish:clientsecretjiberish"
  uri.path =&gt; '/users'
  uri.scheme =&gt; 'https'
  </code></pre>
  
  <p>The problem rises when the userinfo part has a forward slash in it. I have no power to change the API that serves the API keys, so I need to figure out a way to extract the mentioned parts of the URI.</p>
  
  <p>Here's an example on what you can test the URI:</p>
  
  <pre><code>url = 'https://clientjiberish:client/secretjiberish@api.example.com/users?username=tralala'
  uri = URI(url)
  </code></pre>
  
  <p>The error:</p>
  
  <blockquote>
    <p>URI::InvalidURIError: bad URI(is not URI?)</p>
  </blockquote>
  
  <p>I found out that you can create your own parser like this:</p>
  
  <pre><code>parser = URI::Parser.new(:RESERVED =&gt; ";/?:@&amp;=+$,\\[\\]")
  uri = parser.parse(url)
  </code></pre>
  
  <p>but I don't know enough about regex to make it work.</p>