URIUtils: fix out of range exception in resolvePath()

Same as #4321.