method
route_from_path
v1_9_2_180 -
Show latest stable
-
0 notes -
Class: URI::Generic
- 1_8_6_287 (0)
- 1_8_7_72 (0)
- 1_8_7_330 (0)
- 1_9_1_378 (0)
- 1_9_2_180 (0)
- 1_9_3_125
- 1_9_3_392
- 2_1_10
- 2_2_9
- 2_4_6
- 2_5_5
- 2_6_3
- What's this?
route_from_path(src, dst)
private
Hide source
# File lib/uri/generic.rb, line 815 def route_from_path(src, dst) # RFC2396, Section 4.2 return '' if src == dst src_path = split_path(src) dst_path = split_path(dst) # hmm... dst has abnormal absolute path, # like "/./", "/../", "/x/../", ... if dst_path.include?('..') || dst_path.include?('.') return dst.dup end src_path.pop # discard same parts while dst_path.first == src_path.first break if dst_path.empty? src_path.shift dst_path.shift end tmp = dst_path.join('/') # calculate if src_path.empty? if tmp.empty? return './' elsif dst_path.first.include?(':') # (see RFC2396 Section 5) return './' + tmp else return tmp end end return '../' * src_path.size + tmp end