summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Gahan <chris@ill-logic.com>2006-01-27 04:57:51 +0000
committerChris Gahan <chris@ill-logic.com>2006-01-27 04:57:51 +0000
commitdb236f7d9c386ff74fe111689e99dfff2a2fc536 (patch)
tree462c9ced71edbed60bffb5b8ff5bafac7f0d2637
parentb16c418dc07ccb0821eb7db986aad859bbc68523 (diff)
Fixed a bug that cut off the query-part of the url, cleaned up the redirect url joining.
-rw-r--r--data/rbot/plugins/url.rb14
1 files changed, 4 insertions, 10 deletions
diff --git a/data/rbot/plugins/url.rb b/data/rbot/plugins/url.rb
index b7e10b3d..a4e96359 100644
--- a/data/rbot/plugins/url.rb
+++ b/data/rbot/plugins/url.rb
@@ -1,7 +1,7 @@
require 'net/http'
require 'uri'
require 'cgi'
-
+
Url = Struct.new("Url", :channel, :nick, :time, :url)
TITLE_RE = /<\s*?title\s*?>(.+?)<\s*?\/title\s*?>/im
@@ -48,21 +48,15 @@ class UrlPlugin < Plugin
# call self recursively if this is a redirect
redirect_to = head['location']
puts "+ redirect location: #{redirect_to}"
- absolute_uris = URI.extract redirect_to
- raise "wtf! redirect = #{redirect_to}" if absolute_uris.size > 1
- if absolute_uris.size == 1
- url = URI.parse absolute_uris[0]
- else
- url.path = redirect_to
- end
- puts "+ whee, redirect to #{url.to_s}!"
+ url = URI.join url.to_s, redirect_to
+ puts "+ whee, redirecting to #{url.to_s}!"
title = get_title_for_url(url.to_s)
when Net::HTTPSuccess then
if head['content-type'] =~ /^text\//
# content is 'text/*'
# retrieve the title from the page
puts "+ getting #{url.path}"
- response = http.request_get(url.path)
+ response = http.request_get(url.request_uri)
return get_title_from_html(response.body)
else
# content isn't 'text/*'... display info about the file.