mirror-chatterino2/src/common/LinkParser.cpp

31 lines
652 B
C++
Raw Normal View History

#include "common/LinkParser.hpp"
#include <QFile>
#include <QRegularExpression>
#include <QString>
#include <QTextStream>
namespace chatterino {
LinkParser::LinkParser(const QString &unparsedString)
{
2019-12-26 22:00:31 +01:00
static QRegularExpression linkRegex(
"^(?:http(s)?:\\/\\/)?[\\w.-]+(?:\\.[\\w\\.-]+)+[\\w\\-\\._~:/"
"?#[\\]@!\\$&'\\(\\)\\*\\+,;=.]+$",
QRegularExpression::CaseInsensitiveOption);
this->match_ = linkRegex.match(unparsedString);
}
2018-08-10 19:00:14 +02:00
bool LinkParser::hasMatch() const
{
return this->match_.hasMatch();
}
QString LinkParser::getCaptured() const
{
return this->match_.captured();
}
} // namespace chatterino