Lagrange [release]

Empty path normalization was not being applied

bee8691b33e4846aa0efd5f343a63cc695f4c4ad
diff --git a/src/gmrequest.c b/src/gmrequest.c
index 82c232e1..603975f0 100644
--- a/src/gmrequest.c
+++ b/src/gmrequest.c
@@ -593,6 +593,15 @@ void setUrl_GmRequest(iGmRequest *d, const iString *url) {
        the web. */
     /* Encode everything except already-percent encoded characters. */
     iString *enc = urlEncodeExclude_String(&d->url, "%" URL_RESERVED_CHARS);
+    /* Normalize empty paths to /. */ {
+        iUrl parts;
+        init_Url(&parts, enc);
+        if (isEmpty_Range(&parts.path) && equalCase_Rangecc(parts.scheme, "gemini") &&
+            parts.path.start) {
+            /* Normalize to "/" as per specification (November 2021 update). */
+            insertData_Block(&enc->chars, parts.path.start - constBegin_String(enc), "/", 1);
+        }
+    }
     set_String(&d->url, enc);
     delete_String(enc);
     d->identity = identityForUrl_GmCerts(d->certs, &d->url);
diff --git a/src/gmutil.c b/src/gmutil.c
index e59e6649..ecfe2128 100644
--- a/src/gmutil.c
+++ b/src/gmutil.c
@@ -325,10 +325,6 @@ void urlEncodePath_String(iString *d) {
         return;
     }
     if (isEmpty_Range(&url.path)) {
-        if (equalCase_Rangecc(url.scheme, "gemini") && url.path.start) {            
-            /* Normalize to "/" as per specification (November 2021 update). */
-            insertData_Block(&d->chars, url.path.start - constBegin_String(d), "/", 1);
-        }        
         return;
     }
     iString *encoded = new_String();