22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/atig/ofilter/short_url.rb', line 22
def short_urls(mesg)
shorten = case
when @opts.bitlify.to_s.include?(":")
login, key, len = @opts.bitlify.to_s.split(":", 3)
@len = (len || MIN_LEN).to_i
Bitly.login @log, login, key
when @opts.bitlify
@len = (@opts.bitlify.to_s || MIN_LEN).to_i
Bitly.no_login @log
when @opts.unuify
@len = (@opts.unuify.to_s || MIN_LEN).to_i
Unu.new @log
else
return mesg
end
mesg.gsub(URI.regexp(%w[http https])) do|url|
if URI.rstrip(url).size < @len then
url
else
shorten.shorten url
end
end
end
|