return false instead of throwing on a url with nothing after the schema

This commit is contained in:
PobreGato
2026-08-31 03:12:39 +03:00
parent 954e98eb4d
commit 039d3feea7
2 changed files with 7 additions and 0 deletions
+1
View File
@@ -133,6 +133,7 @@ namespace http
}
/* hostname[:port][/path] */
if (pos_p >= url.length ()) return false; /* nothing left after schema or user part */
if (url.at(pos_p) == '[') // ipv6
{
auto pos_b = url.find(']', pos_p);
+6
View File
@@ -125,6 +125,12 @@ int main() {
assert(url->frag == "frag");
delete url;
/* nothing after the schema or the user part: must not throw */
url = new URL;
assert(url->parse("http://") == false);
assert(url->parse("http://user@") == false);
delete url;
return 0;
}