]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
urlapi: skip path checks if path is just "/"
authorDaniel Stenberg <daniel@haxx.se>
Wed, 1 Feb 2023 07:26:08 +0000 (08:26 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 1 Feb 2023 22:04:45 +0000 (23:04 +0100)
As a miniscule optimization, treat a path of the length 1 as the same as
non-existing, as it can only be a single leading slash, and that's what
we do for no paths as well.

Closes #10385

lib/urlapi.c

index baaf4af733a9620190ad19a18190ccfc1d538c09..ef9ec4169f6b2c7761ec3a3297cb2368514a6078 100644 (file)
@@ -1200,9 +1200,10 @@ static CURLUcode parseurl(const char *url, CURLU *u, unsigned int flags)
     path = u->path = Curl_dyn_ptr(&enc);
   }
 
-  if(!pathlen) {
-    /* there is no path left, unset */
+  if(pathlen <= 1) {
+    /* there is no path left or just the slash, unset */
     path = NULL;
+    pathlen = 0;
   }
   else {
     if(!u->path) {