From 590a7c7dfa4fe6054f9b9fb0a40cf08e6776accb Mon Sep 17 00:00:00 2001 From: das_ <35780068+daspositioned@users.noreply.github.com> Date: Thu, 29 Jan 2026 06:08:00 +0100 Subject: [PATCH] Fix Discord details url exceeding max length (#1620) * fix discord details url exceeding max length --- src/renderer/features/discord-rpc/use-discord-rpc.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/renderer/features/discord-rpc/use-discord-rpc.ts b/src/renderer/features/discord-rpc/use-discord-rpc.ts index 2b78b291d..633f2ad7a 100644 --- a/src/renderer/features/discord-rpc/use-discord-rpc.ts +++ b/src/renderer/features/discord-rpc/use-discord-rpc.ts @@ -26,6 +26,7 @@ const discordRpc = isElectron() ? window.api.discordRpc : null; type ActivityState = [QueueSong | undefined, number, PlayerStatus]; const MAX_FIELD_LENGTH = 127; +const MAX_URL_LENGTH = 256; const truncate = (field: string) => field.length <= MAX_FIELD_LENGTH ? field : field.substring(0, MAX_FIELD_LENGTH - 1) + '…'; @@ -163,13 +164,19 @@ export const useDiscordRpc = () => { ) { activity.stateUrl = 'https://www.last.fm/music/' + encodeURIComponent(song.artists[0].name); - activity.detailsUrl = + + const detailsUrl = 'https://www.last.fm/music/' + encodeURIComponent(song.albumArtists[0].name) + '/' + encodeURIComponent(song.album || '_') + '/' + encodeURIComponent(song.name); + + // The details URL has a max length, only set it if it doesn't exceed it + if (detailsUrl.length <= MAX_URL_LENGTH) { + activity.detailsUrl = detailsUrl; + } } if (