mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
fix: use the full url when resolving (#5345)
This commit is contained in:
parent
1a04bda56b
commit
dfa929e207
|
@ -2,6 +2,8 @@
|
|||
|
||||
## Unversioned
|
||||
|
||||
- Bugfix: Fixed links without a protocol not being clickable. (#5345)
|
||||
|
||||
## 2.5.0
|
||||
|
||||
- Major: Twitch follower emotes can now be correctly tabbed in other channels when you are subscribed to the channel the emote is from. (#4922)
|
||||
|
|
|
@ -12,9 +12,28 @@ struct ParsedLink {
|
|||
#else
|
||||
using StringView = QStringRef;
|
||||
#endif
|
||||
/// The parsed protocol of the link. Can be empty.
|
||||
///
|
||||
/// https://www.forsen.tv/commands
|
||||
/// ^------^
|
||||
StringView protocol;
|
||||
|
||||
/// The parsed host of the link. Can not be empty.
|
||||
///
|
||||
/// https://www.forsen.tv/commands
|
||||
/// ^-----------^
|
||||
StringView host;
|
||||
|
||||
/// The remainder of the link. Can be empty.
|
||||
///
|
||||
/// https://www.forsen.tv/commands
|
||||
/// ^-------^
|
||||
StringView rest;
|
||||
|
||||
/// The original unparsed link.
|
||||
///
|
||||
/// https://www.forsen.tv/commands
|
||||
/// ^----------------------------^
|
||||
QString source;
|
||||
};
|
||||
|
||||
|
|
|
@ -617,16 +617,16 @@ void MessageBuilder::addLink(const ParsedLink &parsedLink)
|
|||
{
|
||||
QString lowercaseLinkString;
|
||||
QString origLink = parsedLink.source;
|
||||
QString matchedLink;
|
||||
QString fullUrl;
|
||||
|
||||
if (parsedLink.protocol.isNull())
|
||||
{
|
||||
matchedLink = QStringLiteral("http://") + parsedLink.source;
|
||||
fullUrl = QStringLiteral("http://") + parsedLink.source;
|
||||
}
|
||||
else
|
||||
{
|
||||
lowercaseLinkString += parsedLink.protocol;
|
||||
matchedLink = parsedLink.source;
|
||||
fullUrl = parsedLink.source;
|
||||
}
|
||||
|
||||
lowercaseLinkString += parsedLink.host.toString().toLower();
|
||||
|
@ -636,8 +636,7 @@ void MessageBuilder::addLink(const ParsedLink &parsedLink)
|
|||
auto *el = this->emplace<LinkElement>(
|
||||
LinkElement::Parsed{.lowercase = lowercaseLinkString,
|
||||
.original = origLink},
|
||||
MessageElementFlag::Text, textColor);
|
||||
el->setLink({Link::Url, matchedLink});
|
||||
fullUrl, MessageElementFlag::Text, textColor);
|
||||
getIApp()->getLinkResolver()->resolve(el->linkInfo());
|
||||
}
|
||||
|
||||
|
|
|
@ -679,10 +679,11 @@ void SingleLineTextElement::addToContainer(MessageLayoutContainer &container,
|
|||
}
|
||||
}
|
||||
|
||||
LinkElement::LinkElement(const Parsed &parsed, MessageElementFlags flags,
|
||||
const MessageColor &color, FontStyle style)
|
||||
LinkElement::LinkElement(const Parsed &parsed, const QString &fullUrl,
|
||||
MessageElementFlags flags, const MessageColor &color,
|
||||
FontStyle style)
|
||||
: TextElement({}, flags, color, style)
|
||||
, linkInfo_(parsed.original)
|
||||
, linkInfo_(fullUrl)
|
||||
, lowercase_({parsed.lowercase})
|
||||
, original_({parsed.original})
|
||||
{
|
||||
|
|
|
@ -272,7 +272,10 @@ public:
|
|||
QString original;
|
||||
};
|
||||
|
||||
LinkElement(const Parsed &parsed, MessageElementFlags flags,
|
||||
/// @param parsed The link as it appeared in the message
|
||||
/// @param fullUrl A full URL (notably with a protocol)
|
||||
LinkElement(const Parsed &parsed, const QString &fullUrl,
|
||||
MessageElementFlags flags,
|
||||
const MessageColor &color = MessageColor::Text,
|
||||
FontStyle style = FontStyle::ChatMedium);
|
||||
~LinkElement() override = default;
|
||||
|
|
Loading…
Reference in a new issue