title: How do I safely join relative url segments?
body: <p>I'm trying to find a robust method of joining partial url path segments together. Is there a quick way to do this?</p>
  
  <p>I tried the following:</p>
  
  <pre><code>puts URI::join('resource/', '/edit', '12?option=test')
  </code></pre>
  
  <p>I expect:</p>
  
  <pre><code>resource/edit/12?option=test
  </code></pre>
  
  <p>But I get the error:</p>
  
  <pre><code>`merge': both URI are relative (URI::BadURIError)
  </code></pre>
  
  <p>I have used <code>File.join()</code> in the past for this but something does not seem right about using the file library for urls.</p>