Sha256: 4e67129e7996d5355ccb46cb11b06f9f32958919e78d3bf9be3915b7c404b20f

Contents?: true

Size: 504 Bytes

Versions: 3

Compression:

Stored size: 504 Bytes

Contents

# frozen_string_literal: true

require 'http'
require 'uri'

module VerifyUrls
  module Helper
    def self.response_success?(response)
      code = response&.code
      code && code >= 200 && code < 300
    end

    def self.GET(url)
      HTTP.follow.get(url)
    rescue HTTP::Error => _e
    end

    def self.absolute_url?(url)
      uri = URI.parse(url)
      return false unless uri.hostname
      return false unless uri.scheme
      return false unless uri.absolute?
      true
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
verify_urls-0.3.2 lib/verify_urls/helper.rb
verify_urls-0.3.1 lib/verify_urls/helper.rb
verify_urls-0.3.0 lib/verify_urls/helper.rb