title: Simple URL cleaning
body: <p>I'm trying to do some basic url cleaning, so that</p>
  
  <pre><code>www.google.com
  www.google.com/
  http://google.com
  http://google.com/
  https://google.com
  https://google.com/ 
  </code></pre>
  
  <p>are replaced by <code>http://www.google.com</code> (or <code>https://www.google.com</code> in case when <code>https://</code> is at the beginning).</p>
  
  <p>Basically I'd like to check if there is <code>http/https</code> at the beginning and <code>/</code> at the end in one regexp.</p>
  
  <p>I was trying something like this:</p>
  
  <p><code>"https://google.com".match(/^(http:\/\/|https:\/\/)(.*)(\/)*$/)</code> in this case I get: 
  <code>=&gt; #&lt;MatchData "https://google.com" 1:"https://" 2:"google.com" 3:nil&gt;</code> 
  which is good.</p>
  
  <p>Unfortunately for:</p>
  
  <p><code>"https://google.com/".match(/^(http:\/\/|https:\/\/)(.*)(\/)*$/)</code> I get: 
  <code>=&gt; #&lt;MatchData "https://google.com/" 1:"https://" 2:"google.com/" 3:nil&gt;</code> and would like to have <code>2:"google.com" 3:"/"</code></p>
  
  <p>Any idea how to do this?</p>