relativize URI

hi.. wondering about this function in various writer-classes:

   # If base_uri is defined, use it to try to make uri relative
    # @param [#to_s] uri
    # @return [String]
    def relativize(uri)
      uri = uri.to_s
      base_uri ? uri.sub(base_uri.to_s, "") : uri
    end

 base /2015/03 shortens /2015/03/10 to /10

URI class has a #route_to/#route_from , which would probably be much slower than a naive string-substitution ...

Received on Wednesday, 11 March 2015 20:27:37 UTC