Apply suggestions from code review

Co-authored-by: Chocobo1 <Chocobo1@users.noreply.github.com>
This commit is contained in:
Zentino 2024-12-18 08:58:58 +08:00 committed by GitHub
commit 9ca45e0827
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -63,7 +63,7 @@ namespace
const QRegularExpression rx {uR"(((<a\s+[^>]*?href|<img\s+[^>]*?src)\s*=\s*["'])((https?|ftp):)?(\/\/[^\/]*)?(\/?[^\/"].*?)(["']))"_s const QRegularExpression rx {uR"(((<a\s+[^>]*?href|<img\s+[^>]*?src)\s*=\s*["'])((https?|ftp):)?(\/\/[^\/]*)?(\/?[^\/"].*?)(["']))"_s
, QRegularExpression::CaseInsensitiveOption}; , QRegularExpression::CaseInsensitiveOption};
const QString normalizedBaseUrl = baseUrl.endsWith(u'/') ? baseUrl : baseUrl + u'/'; const QString normalizedBaseUrl = baseUrl.endsWith(u'/') ? baseUrl : (baseUrl + u'/');
const QUrl url {normalizedBaseUrl}; const QUrl url {normalizedBaseUrl};
const QString defaultScheme = url.scheme(); const QString defaultScheme = url.scheme();
QRegularExpressionMatchIterator iter = rx.globalMatch(html); QRegularExpressionMatchIterator iter = rx.globalMatch(html);
@ -87,7 +87,7 @@ namespace
relativePath = relativePath.mid(1); relativePath = relativePath.mid(1);
const QString absoluteUrl = !host.isEmpty() const QString absoluteUrl = !host.isEmpty()
? QString(defaultScheme + u":" + host) : QString(normalizedBaseUrl + relativePath); ? QString(defaultScheme + u':' + host) : (normalizedBaseUrl + relativePath);
const QString fullMatch = match.captured(0); const QString fullMatch = match.captured(0);
const QString prefix = match.captured(1); const QString prefix = match.captured(1);
const QString suffix = match.captured(7); const QString suffix = match.captured(7);