Files
keepassxc/tests/TestUrlTools.h
Adrien Ollier ce28e2afb7 Refactor UrlTools to be a namespace
UrlTools does not need to inherit from QObject or even be a class.
It is a collection of regular functions.
refactor(urltools): Make regular expression static

domainHasIllegalCharacters() constructs a QRegularExpression on every call.
Since the pattern is constant, make it static const QRegularExpression
  to avoid repeated regex compilation in hot paths
  (e.g., domain validation during browsing/passkey operations).

refactor(urltools): Remove the unnecessary convertVariantToUrl function

format code

refactor(urltools): Include What You Use

refactor(urltools): Use URL_WILDCARD directly in implementation

refactor(urltools): some more inprovements

- code format
- use pure Qt functions for the string handling
- use chop to remove the last character of a QString
- make another QRegularExpression static const
2026-06-29 08:55:10 -04:00

39 lines
1.2 KiB
C++

/*
* Copyright (C) 2025 KeePassXC Team <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 or (at your option)
* version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KEEPASSXC_TESTURLTOOLS_H
#define KEEPASSXC_TESTURLTOOLS_H
#include "gui/UrlTools.h"
#include <QObject>
#include <QPointer>
class TestUrlTools : public QObject
{
Q_OBJECT
private slots:
void initTestCase();
void testTopLevelDomain();
void testIsIpAddress();
void testIsUrlIdentical();
void testIsUrlValid();
void testIsUrlValidWithLooseComparison();
void testDomainHasIllegalCharacters();
};
#endif // KEEPASSXC_TESTURLTOOLS_H