Sha256: 10bc620043432cca8b27a404ddb6e8bd87519e284afc6dd2a6e6df6679fc0324
Contents?: true
Size: 872 Bytes
Versions: 2
Compression:
Stored size: 872 Bytes
Contents
require 'uri' module BerkeleyLibrary module Util module URIs module Validator class << self # Returns the specified URL as a URI. # @param url [String, URI] the URL. # @return [URI] the URI. # @raise [URI::InvalidURIError] if `url` cannot be parsed as a URI. def uri_or_nil(url) return unless url # noinspection RubyYardReturnMatch url.is_a?(URI) ? url : URI.parse(url.to_s) end # Returns the specified URL as a string. # @param url [String, URI] the URL. # @return [String] the URL. # @raise [URI::InvalidURIError] if `url` cannot be parsed as a URI. def url_str_or_nil(url) uri = Validator.uri_or_nil(url) uri.to_s if uri end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
berkeley_library-tind-0.4.1 | lib/berkeley_library/util/uris/validator.rb |
berkeley_library-tind-0.4.0 | lib/berkeley_library/util/uris/validator.rb |