MCPcopy Create free account
hub / github.com/LeFroid/Viper-Browser / getRegExp

Method getRegExp

src/core/user_scripts/UserScript.cpp:152–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

150}
151
152QRegularExpression 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
175QString UserScript::getScriptJSON() const
176{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected