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