| 150 | } |
| 151 | |
| 152 | QRegularExpression UserScript::getRegExp(const QString &str) |
| 153 | { |
| 154 | // Check if string is either a single '*' or empty, and if so, set regular expression to match everything |
| 155 | if (str.isEmpty() || (str.size() == 1 && str.at(0) == '*')) |
| 156 | return QRegularExpression(QStringLiteral(".*")); |
| 157 | |
| 158 | QString converted; |
| 159 | |
| 160 | // Check if rule is a regular expression |
| 161 | if (str.startsWith('/') && str.endsWith('/')) |
| 162 | { |
| 163 | converted = str.mid(1); |
| 164 | converted = str.left(str.size() - 1); |
| 165 | converted.replace(QStringLiteral("\\"), QStringLiteral("\\\\")); |
| 166 | return QRegularExpression(converted); |
| 167 | } |
| 168 | |
| 169 | // If the method has not returned at this point, replace each occurrence of a "*" with a ".*" |
| 170 | converted = str; |
| 171 | converted.replace(QStringLiteral("*"), QStringLiteral(".*")); |
| 172 | return QRegularExpression(converted); |
| 173 | } |
| 174 | |
| 175 | QString UserScript::getScriptJSON() const |
| 176 | { |
nothing calls this directly
no outgoing calls
no test coverage detected