From b7bf131195349b1a26fe646e5c8d1b0217813ad2 Mon Sep 17 00:00:00 2001 From: Soren Stoutner Date: Tue, 24 Jun 2025 15:13:49 -0700 Subject: [PATCH] Fix URL syntax highlighting when no schema is specified. https://redmine.stoutner.com/issues/1280 --- src/widgets/UrlLineEdit.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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); -- 2.47.2