Files
plezy/lib/utils/plex_url_helper.dart
edde746 5fe1e6dc65 refactor(ui): delete unwired log output, dead notifier filters, and never-passed widget params
MemoryLogOutput extended LogOutput but was never wired as a Logger output (storage happens in the printer); DeletionNotifier/WatchStateNotifier's forServer/forItem filtered streams and WatchStateEvent.mediaType had no production consumers (tests now filter .stream directly); context.hiddenLibraries/profileSettings and toPlexUrl had zero call sites; MonoTokens.splashFactory was never read; OptimizedMediaImage's enableTranscoding/cacheKey chains, FocusableMediaCard.width/height/forceGridMode, TvBrowseRail's constant-zero gap functions, and media_image_helper's scaleFactor were never varied by any caller. The sha1 LRU stays (rebuild-hot artwork URLs); TvRailTrailing.none and the mono-theme copyWith stay live (lerp delegates to copyWith). Also carries the MusicPlayContext.id argument drops in the music screens and remaining sweep test updates.
2026-08-17 19:02:25 +02:00

24 lines
917 B
Dart

/// Extension methods for appending Plex authentication tokens to URLs.
extension PlexUrlExtension on String {
/// Appends a Plex authentication token to this URL string.
///
/// Automatically determines whether to use '?' or '&' as the separator
/// based on whether the URL already contains query parameters.
///
/// If [token] is null or empty, returns the URL unchanged.
///
/// Example:
/// ```dart
/// final url = '/library/metadata/123'.withPlexToken('abc123');
/// // Result: '/library/metadata/123?X-Plex-Token=abc123'
///
/// final urlWithParams = '/library/metadata/123?type=1'.withPlexToken('abc123');
/// // Result: '/library/metadata/123?type=1&X-Plex-Token=abc123'
/// ```
String withPlexToken(String? token) {
if (token == null || token.isEmpty) return this;
final separator = contains('?') ? '&' : '?';
return '$this${separator}X-Plex-Token=$token';
}
}