Module: Sidewalk::RootedUri
- Defined in:
- lib/sidewalk/rooted_uri.rb
Overview
A URI relative to a specified root URI.
You probably don’t want to use this directly - see AppUri and RelativeUri for examples.
Class Method Summary collapse
-
.new(root, path, query = {}) ⇒ Object
Create a new URI, relative to the specified root.
Class Method Details
.new(root, path, query = {}) ⇒ Object
Create a new URI, relative to the specified root.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/sidewalk/rooted_uri.rb', line 15 def self.new root, path, query = {} uri = root.dup root_path = uri.path root_path = root_path[0..-2] if root_path.end_with? '/' uri.path = root_path + path query_string = query.map do |k,v| '%s=%s' % [ Rack::Utils.escape(k.to_s), Rack::Utils.escape(v.to_s), ] end.join('&') uri.query = query_string unless query.empty? uri end |