From: Soren Stoutner Date: Tue, 24 Jun 2025 22:13:49 +0000 (-0700) Subject: Fix URL syntax highlighting when no schema is specified. https://redmine.stoutner... X-Git-Url: https://gitweb.stoutner.com/?a=commitdiff_plain;h=b7bf131195349b1a26fe646e5c8d1b0217813ad2;p=PrivacyBrowserPC.git Fix URL syntax highlighting when no schema is specified. https://redmine.stoutner.com/issues/1280 --- diff --git a/src/widgets/UrlLineEdit.cpp b/src/widgets/UrlLineEdit.cpp index 6a8ee91..73583a0 100644 --- a/src/widgets/UrlLineEdit.cpp +++ b/src/widgets/UrlLineEdit.cpp @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-3.0-or-later - * SPDX-FileCopyrightText: 2024 Soren Stoutner + * SPDX-FileCopyrightText: 2024-2025 Soren Stoutner * * This file is part of 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);