/* 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/>.
*
// 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);