Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
URI::Generic#check_opaque
(::String? v) -> true?
check_opaque(v)
lib/uri/generic.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/lib/uri/generic.rb, line 876
def check_opaque(v)
return v unless v
# raise if both hier and opaque are not nil, because:
# absoluteURI = scheme ":" ( hier_part | opaque_part )
# hier_part = ( net_path | abs_path ) [ "?" query ]
if @host || @port || @user || @path # userinfo = @user + ':' + @password
raise InvalidURIError,
"cannot set opaque with host, port, userinfo or path"
elsif v && parser.regexp[:OPAQUE] !~ v
raise InvalidComponentError,
"bad component(expected opaque component): #{v}"
end
return true
end
Checks the opaque v component for RFC2396 compliance and against the parser Regexp for :OPAQUE.
Can not have a host, port, user, or path component defined, with an opaque component defined.
See also
#check_host
#check_password
#authority
#check_path
also in
4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0