-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for premium audios inside podcast posts one the web
- Loading branch information
1 parent
de8930d
commit ee5e8f8
Showing
2 changed files
with
61 additions
and
6 deletions.
There are no files selected for viewing
12 changes: 6 additions & 6 deletions
12
gabimoreno/src/main/java/soy/gabimoreno/domain/util/ExtractMp3Url.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
package soy.gabimoreno.domain.util | ||
|
||
import androidx.annotation.VisibleForTesting | ||
|
||
fun String.extractMp3Url(): String? { | ||
val startIndex = indexOf(PREFIX) | ||
val suffix = SUFFIX | ||
val suffixLength = suffix.length | ||
val endIndex = indexOf(suffix) + suffixLength | ||
var endIndex = indexOf(suffix) + suffixLength | ||
if (endIndex <= startIndex) { | ||
endIndex += substring(endIndex, length).indexOf(suffix) + suffixLength | ||
} | ||
|
||
if (startIndex == -1 || endIndex == suffixLength - 1) return null | ||
return substring(startIndex, endIndex) | ||
} | ||
|
||
@VisibleForTesting | ||
internal const val PREFIX = "https://gabimoreno.soy/wp-content/uploads/" | ||
internal const val SUFFIX = ".mp3" | ||
private const val PREFIX = "https://gabimoreno.soy/wp-content/uploads/" | ||
private const val SUFFIX = ".mp3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters