refactor(urltools): UrlTools is now a namespace#13258
Open
aollier wants to merge 6 commits intokeepassxreboot:developfrom
Open
refactor(urltools): UrlTools is now a namespace#13258aollier wants to merge 6 commits intokeepassxreboot:developfrom
aollier wants to merge 6 commits intokeepassxreboot:developfrom
Conversation
4c5f8e9 to
682d6f1
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors UrlTools from a QObject-based singleton to a pure function collection under the UrlTools namespace, updating callers and tests accordingly.
Changes:
- Replace
UrlToolsclass/singleton (urlTools()) usage withUrlTools::...namespace function calls. - Remove singleton/test fixture setup that is no longer needed.
- Adjust
UrlToolsimplementation to use internal free helpers instead of private member methods.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/TestUrlTools.h | Removes unused test lifecycle hooks and singleton member usage. |
| tests/TestUrlTools.cpp | Updates tests to call UrlTools::... namespace functions directly. |
| src/gui/entry/EntryURLModel.cpp | Switches URL validation/dup-check logic to UrlTools::... calls. |
| src/gui/UrlTools.h | Converts the public API from a class to a UrlTools namespace of functions/constants. |
| src/gui/UrlTools.cpp | Removes singleton implementation; introduces internal helpers; adapts functions to namespace form. |
| src/gui/URLEdit.cpp | Updates URL validation call to UrlTools::isUrlValid. |
| src/gui/IconDownloader.cpp | Updates domain and redirect handling calls to UrlTools::.... |
| src/browser/PasskeyUtils.cpp | Updates public-suffix/domain validation helpers to use UrlTools::.... |
| src/browser/BrowserService.cpp | Updates base-domain comparison to use UrlTools::getBaseDomainFromUrl. |
e3b9704 to
2832f90
Compare
varjolintu
reviewed
Apr 24, 2026
varjolintu
reviewed
Apr 24, 2026
varjolintu
requested changes
Apr 24, 2026
Member
varjolintu
left a comment
There was a problem hiding this comment.
Fix the suggestions + code format in UrlTools.h. Let's see if any build errors appear.
Contributor
Author
UrlTools does not need to inherit from QObject or even be a class. It is a collection of regular functions.
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).
- 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
340c234 to
b089b54
Compare
varjolintu
reviewed
Apr 26, 2026
varjolintu
approved these changes
Apr 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
UrlTools does not need to inherit from QObject or even be a class. It is a collection of regular functions.
Type of change