]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/commitdiff
Fix URL syntax highlighting when no schema is specified. https://redmine.stoutner...
authorSoren Stoutner <soren@stoutner.com>
Tue, 24 Jun 2025 22:13:49 +0000 (15:13 -0700)
committerSoren Stoutner <soren@stoutner.com>
Tue, 24 Jun 2025 22:13:49 +0000 (15:13 -0700)
src/widgets/UrlLineEdit.cpp

index 6a8ee91aa690e6c9db969df138b25fe8f7691c1a..73583a056cf5da5edfdbb498543bb9aac4504646 100644 (file)
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: GPL-3.0-or-later
- * SPDX-FileCopyrightText: 2024 Soren Stoutner <soren@stoutner.com>
+ * SPDX-FileCopyrightText: 2024-2025 Soren Stoutner <soren@stoutner.com>
  *
  * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc/>.
  *
@@ -64,8 +64,12 @@ void UrlLineEdit::setText(const QString &urlString)
         // Calculate the URL string length.
         int urlStringLength = urlString.length();
 
-        // Get the index of end of the schema.
-        int endOfSchemaIndex = urlString.indexOf(QLatin1String("//")) + 2;
+        // Initialize the end of schema index.
+        int endOfSchemaIndex = 0;
+
+        // Get the index of the end of the schema if it exists.
+        if (urlString.contains(QLatin1String("//")))
+            endOfSchemaIndex = urlString.indexOf(QLatin1String("//")) + 2;
 
         // Get the index of the `/` immediately after the domain name.  If this doesn't exit it will be set to `-1`.
         int endOfDomainNameIndex = urlString.indexOf(QLatin1Char('/'), endOfSchemaIndex);