Lagrange [work/v1.9]

InputWidget: Re-fixing parsing a simple "hostname:port" input

=> f9ee0a6e3a4c9fa0c72def689a17d08394035d60

diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c
index fa3ce368..653057af 100644
--- a/src/ui/inputwidget.c
+++ b/src/ui/inputwidget.c
@@ -41,6 +41,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1015,10 +1016,16 @@ static const iString *omitDefaultScheme_(iString *url) {
 const iString *text_InputWidget(const iInputWidget *d) {
     iString *text = collect_String(d ? text_InputWidget_(d) : new_String());
     if (d && d->inFlags & isUrl_InputWidgetFlag) {
-        /* Add the "gemini" scheme back if one is omitted. */
-        //restoreDefaultScheme_(text);
-        
-        /* TODO: Check for `hostname:port` pattern and fit it so it'll be parsed correctly. */
+        /* Check for `hostname:port` pattern and fit it so it'll be parsed correctly. */
+        static iRegExp *simpleHost;
+        if (!simpleHost) {
+            simpleHost = new_RegExp("^[\\w.-]+:\\d{1,5}$", caseInsensitive_RegExpOption);
+        }
+        iRegExpMatch m;
+        init_RegExpMatch(&m);
+        if (matchString_RegExp(simpleHost, text, &m)) {
+            prependCStr_String(text, "gemini://");
+        }
     }
     return text;
 }
Proxy Information
Original URL
gemini://git.skyjake.fi/lagrange/work%2Fv1.9/cdiff/f9ee0a6e3a4c9fa0c72def689a17d08394035d60
Status Code
Success (20)
Meta
text/gemini; charset=utf-8
Capsule Response Time
70.070208 milliseconds
Gemini-to-HTML Time
0.175681 milliseconds

This content has been proxied by September (3851b).