Changeset View
Changeset View
Standalone View
Standalone View
src/urifilters/shorturi/kshorturifilter.cpp
Show First 20 Lines • Show All 426 Lines • ▼ Show 20 Line(s) | 426 | } else { | |||
---|---|---|---|---|---|
427 | setUriType(data, KUriFilterData::NetProtocol); | 427 | setUriType(data, KUriFilterData::NetProtocol); | ||
428 | } | 428 | } | ||
429 | return true; | 429 | return true; | ||
430 | } | 430 | } | ||
431 | } | 431 | } | ||
432 | 432 | | |||
433 | // Short url matches | 433 | // Short url matches | ||
434 | if (!cmd.contains(QLatin1Char(' '))) { | 434 | if (!cmd.contains(QLatin1Char(' '))) { | ||
435 | // Okay this is the code that allows users to supply custom matches for | 435 | // Okay this is the code that allows users to supply custom matches for specific | ||
436 | // specific URLs using Qt's regexp class. This is hard-coded for now. | 436 | // URLs using Qt's QRegularExpression class. | ||
dfaure: (before I forget: this todo should be removed, `KShortUriFilter::configure()` does exactly that) | |||||
437 | // TODO: Make configurable at some point... | | |||
438 | for (const URLHint &hint : qAsConst(m_urlHints)) { | 437 | for (const URLHint &hint : qAsConst(m_urlHints)) { | ||
439 | qCDebug(category) << "testing regexp for" << hint.prepend; | 438 | qCDebug(category) << "testing regexp for" << hint.prepend; | ||
440 | if (hint.regexp.indexIn(cmd) == 0) { | 439 | if (hint.hintRe.match(cmd).capturedStart() == 0) { | ||
441 | const QString cmdStr = hint.prepend + cmd; | 440 | const QString cmdStr = hint.prepend + cmd; | ||
442 | QUrl url(cmdStr); | 441 | QUrl url(cmdStr); | ||
443 | qCDebug(category) << "match - prepending" << hint.prepend << "->" << cmdStr << "->" << url; | 442 | qCDebug(category) << "match - prepending" << hint.prepend << "->" << cmdStr << "->" << url; | ||
444 | setFilteredUri(data, url); | 443 | setFilteredUri(data, url); | ||
445 | setUriType(data, hint.type); | 444 | setUriType(data, hint.type); | ||
446 | return true; | 445 | return true; | ||
447 | } | 446 | } | ||
448 | } | 447 | } | ||
▲ Show 20 Lines • Show All 85 Lines • Show Last 20 Lines |
(before I forget: this todo should be removed, KShortUriFilter::configure() does exactly that)