Sha256: 5c68fd9b8c7075a646dbde5c5e11b9ef138c3a7f09875844e7ab7476d306c3fc
Contents?: true
Size: 1.3 KB
Versions: 4
Compression:
Stored size: 1.3 KB
Contents
# frozen_string_literal: true ## # # module ConvenientService module Examples module Standard module V1 class RequestParams module Utils module URL ## # TODO: Use to validate URLs. # class Valid < ConvenientService::Command attr_reader :url def initialize(url) @url = url end ## # NOTE: How to validate URLs? # - https://storck.io/posts/better-http-url-validation-in-ruby-on-rails # - https://github.com/sporkmonger/addressable/issues/1452 # # NOTE: URL is NOT URI. # - https://stackoverflow.com/a/16359999/12201472 # - https://stackoverflow.com/a/13041565/12201472 # # NOTE: Why NOT to match `URI::regexp`? # - https://bugs.ruby-lang.org/issues/6520 # def call uri = ::URI.parse(url.to_s) uri.is_a?(::URI::HTTPS) || uri.is_a?(::URI::HTTP) rescue ::URI::InvalidURIError false end end end end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems