Top Level Namespace
Defined Under Namespace
Modules: DeadFinder
Instance Method Summary collapse
Instance Method Details
#generate_url(text, base_url) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/deadfinder/utils.rb', line 5 def generate_url(text, base_url) node = text.to_s return node if node.start_with?('http://', 'https://') begin uri = URI(base_url) if node.start_with?('//') "#{uri.scheme}:#{node}" elsif node.start_with?('/') "#{uri.scheme}://#{uri.host}#{node}" elsif ignore_scheme?(node) nil else URI.join(base_url, node).to_s end rescue StandardError nil end end |
#ignore_scheme?(url) ⇒ Boolean
25 26 27 |
# File 'lib/deadfinder/utils.rb', line 25 def ignore_scheme?(url) url.start_with?('mailto:', 'tel:', 'sms:', 'data:', 'file:') end |