From 7c97e6bcc748755ee55447096ebc657be11b4789 Mon Sep 17 00:00:00 2001 From: Maverick Date: Thu, 18 Apr 2024 17:49:50 +0200 Subject: [PATCH] Change order of query parameters of Twitch Player URLs. (#5326) This ensures that it doesn't "fake redirect". Co-authored-by: Rasmus Karlsson --- CHANGELOG.md | 1 + src/common/Common.hpp | 3 +++ src/providers/twitch/TwitchChannel.cpp | 3 +-- src/singletons/Toasts.cpp | 6 +++--- src/widgets/splits/Split.cpp | 3 +-- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b3d60bdc7..8c19a0de8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - Bugfix: Fixed links having `http://` added to the beginning in certain cases. (#5323) - Bugfix: Fixed topmost windows from losing their status after opening dialogs on Windows. (#5330) - Bugfix: Fixed a gap appearing when using filters on `/watching`. (#5329) +- Dev: Changed the order of the query parameters for Twitch player URLs. (#5326) ## 2.5.0-beta.1 diff --git a/src/common/Common.hpp b/src/common/Common.hpp index 35b8efb1c..8d6097473 100644 --- a/src/common/Common.hpp +++ b/src/common/Common.hpp @@ -14,6 +14,9 @@ namespace chatterino { +const inline auto TWITCH_PLAYER_URL = + QStringLiteral("https://player.twitch.tv/?channel=%1&parent=twitch.tv"); + enum class HighlightState { None, Highlighted, diff --git a/src/providers/twitch/TwitchChannel.cpp b/src/providers/twitch/TwitchChannel.cpp index 39350b69c..c478b9191 100644 --- a/src/providers/twitch/TwitchChannel.cpp +++ b/src/providers/twitch/TwitchChannel.cpp @@ -84,8 +84,7 @@ TwitchChannel::TwitchChannel(const QString &name) , nameOptions{name, name, name} , subscriptionUrl_("https://www.twitch.tv/subs/" + name) , channelUrl_("https://twitch.tv/" + name) - , popoutPlayerUrl_("https://player.twitch.tv/?parent=twitch.tv&channel=" + - name) + , popoutPlayerUrl_(TWITCH_PLAYER_URL.arg(name)) , bttvEmotes_(std::make_shared()) , ffzEmotes_(std::make_shared()) , seventvEmotes_(std::make_shared()) diff --git a/src/singletons/Toasts.cpp b/src/singletons/Toasts.cpp index 51dbf4680..3ca5b6e0c 100644 --- a/src/singletons/Toasts.cpp +++ b/src/singletons/Toasts.cpp @@ -1,6 +1,7 @@ #include "Toasts.hpp" #include "Application.hpp" +#include "common/Common.hpp" #include "common/Literals.hpp" #include "common/QLogging.hpp" #include "common/Version.hpp" @@ -177,9 +178,8 @@ public: case ToastReaction::OpenInPlayer: if (platform_ == Platform::Twitch) { - QDesktopServices::openUrl(QUrl( - u"https://player.twitch.tv/?parent=twitch.tv&channel=" % - channelName_)); + QDesktopServices::openUrl( + QUrl(TWITCH_PLAYER_URL.arg(channelName_))); } break; case ToastReaction::OpenInStreamlink: { diff --git a/src/widgets/splits/Split.cpp b/src/widgets/splits/Split.cpp index 1e4c228ef..81b0e2f65 100644 --- a/src/widgets/splits/Split.cpp +++ b/src/widgets/splits/Split.cpp @@ -836,8 +836,7 @@ void Split::openChannelInBrowserPlayer(ChannelPtr channel) if (auto *twitchChannel = dynamic_cast(channel.get())) { QDesktopServices::openUrl( - "https://player.twitch.tv/?parent=twitch.tv&channel=" + - twitchChannel->getName()); + QUrl(TWITCH_PLAYER_URL.arg(twitchChannel->getName()))); } }