lib/turbo-sprockets/asset_resolver.rb
# Operates like File.join, but on segments of a URL. Specifically, it makes
# sure the segments are conjoined by only one forward slash. The URI class
# is also capable of doing this, but is much more difficult to use. Note
# that this method doesn't consider whether or not the segments are relative
# or absolute - it simply joins them.
#
# Examples:
#   UrlMethods.join('/foo/', '/bar', '/baz/')
#     => 'foo/bar/baz'
#
#   UrlMethods.join('http://foo.com', 'bar/', '/baz')
#     # => 'http://foo.com/bar/baz'
#
Operates like File.join, but on segments of a URL. Specifically, it makes
sure the segments are conjoined by only one forward slash. The URI class
is also capable of doing this, but is much more difficult to use. Note
that this method doesn't consider whether or not the segments are relative
or absolute - it simply joins them.




Operates like File . join but on segments of a URL . Specifically it makes sure the segments are conjoined by only one forward slash . The URI class is also capable of doing this but is much more difficult to use . Note that this method doesn ' t consider whether or not the segments are relative or absolute - it simply joins them .
def url_join(*segments)
        segments.compact!
        joined = segments.map { |p| p.sub(/\A\/?(.*?)\/?\z/, "\\1") }.join('/')
        segments.first.start_with?('/') ? "/#{joined}" : joined
      end
def url_join ( * segments ) segments . compact! joined = segments . map { | p | p . sub ( / \A \/ ?(.*?) \/ ? \z / , "\\1" ) } . join ( '/' ) segments . first . start_with? ( '/' ) ? "/#{joined}" : joined end
Operates like File.join, but on segments of a URL.
Operates like File . join but on segments of a URL .
# this regex strips off leading and trailing forward slashes # handle absolute URLs
segments