toFullUrl method
Implementation
String toFullUrl(String originalM3u8Url) {
// Extract base URL from the original full URL
if (contains("https://")) {
return this;
}
Uri uri = Uri.parse(originalM3u8Url);
String baseUrl =
'${uri.scheme}://${uri.authority}/${uri.pathSegments.join('/')}';
// Check if the URL already contains the protocol (is a full URL)
if (!startsWith('http://') && !startsWith('https://')) {
// Append the relative URL to the base URL
if (!startsWith('/')) {
return '$baseUrl/$this';
} else {
return baseUrl + this;
}
}
// If already a full URL, return it as is
return this;
}