End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
URI::Generic#check_path
check_path(v)
lib/uri/generic.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.1.3/lib/uri/generic.rb, line 747
def check_path(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 v && @opaque
raise InvalidURIError,
"path conflicts with opaque"
end
# If scheme is ftp, path may be relative.
# See RFC 1738 section 3.2.2, and RFC 2396.
if @scheme && @scheme != "ftp"
if v && v != '' && parser.regexp[:ABS_PATH] !~ v
raise InvalidComponentError,
"bad component(expected absolute path component): #{v}"
end
else
if v && v != '' && parser.regexp[:ABS_PATH] !~ v &&
parser.regexp[:REL_PATH] !~ v
raise InvalidComponentError,
"bad component(expected relative path component): #{v}"
end
end
return true
end
Checks the path v component for RFC2396 compliance and against the URI::Parser Regexp for :ABS_PATH and :REL_PATH.
Can not have a opaque component defined, with a path component defined.
See also
#check_password
#check_port
#check_opaque
#check_scheme
also in
4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0