Skip to content

Instantly share code, notes, and snippets.

@slyphon
Forked from djberg96/uri_demo.rb
Created November 5, 2011 02:12
Show Gist options
  • Save slyphon/1340992 to your computer and use it in GitHub Desktop.
Save slyphon/1340992 to your computer and use it in GitHub Desktop.
Appending a path to a URI
require 'uri'
s1 = "http://storage.blah.com/auth28173"
s2 = "/container/path/to/object"
u = URI.parse(s1)
ary = s2.split('/')
ary.shift if ary[0].empty?
u.path = [u.path.split('/'), ary].flatten.join('/')
puts u
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment