lib/webmaster_tools.rb in webmaster_tools-0.1.0 vs lib/webmaster_tools.rb in webmaster_tools-0.1.1

- old
+ new

@@ -92,21 +92,22 @@ hash[key.downcase.gsub(' ', '_').to_sym] = value.gsub(/\D/, '').to_i hash end end - def remove_url(url, file) - url = CGI::escape norm_url(url) - page = agent.get(REMOVAL % [url, url + file]) + def remove_url(url_with_file) + url = CGI::escape norm_url(url_with_file) + page = agent.get(REMOVAL % [url, CGI::escape(url_with_file)]) page = agent.submit page.form + raise "could not submit URL" unless page.search(".wmt-external-url").map(&:text).include?(url_with_file) end private def agent @agent ||= Mechanize.new end def norm_url(url) - schema, host = url.scan(/^(https?:\/\/)?(.+?)\/?$/).flatten + schema, host, _ = url.scan(/^(https?:\/\/)?(.+?)(\/.*)?$/).flatten "#{schema || 'http://'}#{host}/" end end