Skip to content

Commit

Permalink
fix(*): remove group from parsing as it made Android API 21 crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibaultBee committed Sep 27, 2023
1 parent 169c1a2 commit 5b4842c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
kotlinVersion = '1.8.0'
dokkaVersion = '1.8.20'
exoPlayerVersion = '1.1.1'
analyticsVersion = '2.0.0'
analyticsVersion = '2.0.1'
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package video.api.player.models

import video.api.player.extensions.parseAsVideoOptions
import video.api.player.utils.Utils
import java.net.URL

/**
Expand Down
6 changes: 5 additions & 1 deletion player/src/main/java/video/api/player/utils/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ object Utils {
fun parseMediaUrl(
mediaUrl: URL
): VideoOptions {
val regex = "https://[^/]+/(?>(?<type>vod|live)/)?(?>.*/)?(?<id>(vi|li)[^/^.]*).*"
/**
* Group naming is not supported before Android API 26 and crashes
* on very old version such as Android API 21
*/
val regex = "https://[^/]+/(?>(vod|live)/)?(?>.*/)?((vi|li)[^/^.]*).*"
val pattern = Pattern.compile(regex)
val matcher = pattern.matcher(mediaUrl.toString())

Expand Down

0 comments on commit 5b4842c

Please sign in to comment.