a11yist/app/lib/link_checker.rb

20 lines
406 B
Ruby
Raw Permalink Normal View History

2024-09-05 22:54:38 +02:00
# frozen_string_literal: true
2024-07-26 00:59:00 +02:00
module LinkChecker
UA = "Mozilla/5.0 (Android 4.4; Mobile; rv:41.0) Gecko/41.0 Firefox/41.0"
2024-09-05 22:54:38 +02:00
module_function
def http(input)
response = Net::HTTP.get_response(URI.parse(input), { 'User-Agent': UA })
2024-07-26 00:59:00 +02:00
case response
when Net::HTTPSuccess
response.uri
when Net::HTTPRedirection
http(response[:location])
else
false
end
end
end