def self.handle_relative_url(doc_url, resolve)
return if doc_url =~ /^http/
if doc_url !~ /^\//
first_char = doc_url[0..0]
doc_url = ( first_char == '?' ? '' : '/' ) + doc_url
if first_char == '?'
current_uri = @@mechanize_doc.uri.to_s
current_uri = @@agent.history.first.uri.to_s if current_uri =~ /\/popup\//
if (current_uri.include? '?')
current_uri = current_uri.scan(/.+\//)[0]
else
current_uri += '/' unless current_uri[-1..-1] == '/'
end
@@current_doc_url = current_uri + doc_url
return
end
end
case resolve
when :full
@@current_doc_url = (@@host_name + doc_url) if ( @@host_name != nil && (doc_url !~ /#{@@host_name}/))
@@current_doc_url = @@current_doc_url.split('/').uniq.join('/')
when :host
base_host_name = (@@host_name.count("/") == 2 ? @@host_name : @@host_name.scan(/(http.+?\/\/.+?)\//)[0][0])
@@current_doc_url = base_host_name + doc_url
else
@@current_doc_url = resolve + doc_url
end
end