Files
plezy/lib/utils/url_utils.dart
T
2026-05-01 01:20:36 +02:00

16 lines
533 B
Dart

/// Backend-neutral URL helpers.
library;
/// Removes a single trailing `/` from [input] so subsequent path joins
/// don't produce double slashes (`http://host//Items` → `http://host/Items`).
/// Trims whitespace first; returns the input unchanged if it has no trailing
/// slash. Empty input returns empty.
String stripTrailingSlash(String input) {
final trimmed = input.trim();
if (trimmed.isEmpty) return trimmed;
if (trimmed.endsWith('/')) {
return trimmed.substring(0, trimmed.length - 1);
}
return trimmed;
}