バグ #471 » openimg.patch
addon/openimg/openimg.rb (作業コピー) | ||
---|---|---|
119 | 119 |
uri = URI.parse(url) |
120 | 120 |
res = Net::HTTP.new(uri.host).get(uri.path, "User-Agent" => Environment::NAME + '/' + Environment::VERSION.to_s) |
121 | 121 |
if(res.is_a?(Net::HTTPResponse)) and (res.code == '200') |
122 |
result = get_tagattr(res.body, element_rule) |
|
123 |
unless result.match(/^https?:/) |
|
124 |
result = "http:"+result end |
|
122 |
address = get_tagattr(res.body, element_rule) |
|
123 |
case address |
|
124 |
when /^https?:/ |
|
125 |
# Complete URL |
|
126 |
result = address |
|
127 |
when /^\/\// |
|
128 |
# No scheme |
|
129 |
result = "http:" + address |
|
130 |
when /^\// |
|
131 |
# Absolute path |
|
132 |
result = uri.dup |
|
133 |
result.path = address |
|
134 |
else |
|
135 |
# Relative path |
|
136 |
result = uri.dup |
|
137 |
result.merge!(address) |
|
138 |
end |
|
125 | 139 |
notice result.inspect |
126 |
result |
|
140 |
result.to_s
|
|
127 | 141 |
else |
128 | 142 |
warn "#{res.code} failed" |
129 | 143 |
nil end |