Sha256: 2212b398e952379d6f2f08bc64e13bd5c094dc513ac1dff64f07fa7816907be7

Contents?: true

Size: 506 Bytes

Versions: 2

Compression:

Stored size: 506 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

2 entries across 2 versions & 1 rubygems

Version Path
verify_urls-0.2.0 lib/verify_urls/helper.rb
verify_urls-0.1.0 lib/verify_urls/helper.rb