class GdsApi::Response

def transform_parsed(value)

def transform_parsed(value)
  return value if @web_urls_relative_to.nil?
  case value
  when Hash
    Hash[value.map { |k, v|
      # NOTE: Don't bother transforming if the value is nil
      if k == 'web_url' && v
        # Use relative URLs to route when the web_url value is on the
        # same domain as the site root. Note that we can't just use the
        # `route_to` method, as this would give us technically correct
        # but potentially confusing `//host/path` URLs for URLs with the
        # same scheme but different hosts.
        relative_url = @web_urls_relative_to.route_to(v)
        [k, relative_url.host ? v : relative_url.to_s]
      else
        [k, transform_parsed(v)]
      end
    }]
  when Array
    value.map { |v| transform_parsed(v) }
  else
    value
  end
end