diff options
author | Rachel Powers <508861+Ryex@users.noreply.github.com> | 2023-03-31 12:29:59 -0700 |
---|---|---|
committer | Rachel Powers <508861+Ryex@users.noreply.github.com> | 2023-05-01 10:47:31 -0700 |
commit | f1028fa66d556b024765ba4e21ac76d4510a3e3e (patch) | |
tree | 1a94095040254ceb02839d3b6e4674efcb7f909e /launcher/net | |
parent | 9d2f0e4dc8fc3995052770c6a7948cb0372fdcbb (diff) | |
download | PrismLauncher-f1028fa66d556b024765ba4e21ac76d4510a3e3e.tar.gz PrismLauncher-f1028fa66d556b024765ba4e21ac76d4510a3e3e.tar.bz2 PrismLauncher-f1028fa66d556b024765ba4e21ac76d4510a3e3e.zip |
fix: properly map progress range
- doument PCRE used for URL compacting
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
Diffstat (limited to 'launcher/net')
-rw-r--r-- | launcher/net/Download.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/launcher/net/Download.cpp b/launcher/net/Download.cpp index a4c3ebfc..3eef9117 100644 --- a/launcher/net/Download.cpp +++ b/launcher/net/Download.cpp @@ -61,13 +61,23 @@ QString truncateUrlHumanFriendly(QUrl &url, int max_len, bool hard_limit = false if (str_url.length() <= max_len) return str_url; - QRegularExpression re(R"(^([\w]+:\/\/)([\w._-]+\/)([\w._-]+\/).*(\/[^]+[^]+)$)"); + /* this is a PCRE regular expression that splits a URL (given by the display rules above) into 5 capture groups + * the scheme (ie https://) is group 1 + * the host (with trailing /) is group 2 + * the first part of the path (with trailing /) is group 3 + * the last part of the path (with leading /) is group 5 + * the remainder of the URL is in the .* and in group 4 + * + * See: https://regex101.com/r/inHkek/1 + * for an interactive breakdown + */ + QRegularExpression re(R"(^([\w]+:\/\/)([\w._-]+\/)([\w._-]+\/)(.*)(\/[^]+[^]+)$)"); auto url_compact = QString(str_url); - url_compact.replace(re, "\\1\\2\\3...\\4"); + url_compact.replace(re, "\\1\\2\\3...\\5"); if (url_compact.length() >= max_len) { - auto url_compact = QString(str_url); - url_compact.replace(re, "\\1\\2...\\4"); + url_compact = QString(str_url); + url_compact.replace(re, "\\1\\2...\\5"); } @@ -120,7 +130,7 @@ void Download::addValidator(Validator* v) void Download::executeTask() { - setStatus(tr("Downloading %1").arg(truncateUrlHumanFriendly(m_url, 60))); + setStatus(tr("Downloading %1").arg(truncateUrlHumanFriendly(m_url, 100))); if (getState() == Task::State::AbortedByUser) { qCWarning(DownloadLogC) << getUid().toString() << "Attempt to start an aborted Download:" << m_url.toString(); |