Sha256: 95ae53d60fe9373fc37281883c9750d40fc6f58a761210e9fa73ef67ca61732e

Contents?: true

Size: 474 Bytes

Versions: 1

Compression:

Stored size: 474 Bytes

Contents

# frozen_string_literal: true

require 'uri'

module SiteHealth
  class Link
    def self.valid?(*args)
      new(*args).valid?
    end

    attr_reader :uri, :url

    def initialize(url)
      @url = url
      @uri = safe_parse_url(@url)
      @valid = @uri.absolute?
    end

    def valid?
      @valid
    end

    private

    # @param [String] url
    def safe_parse_url(url)
      URI.parse(url)
    rescue URI::InvalidURIError
      URI.parse('')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
site_health-0.2.0 lib/site_health/link.rb