Skip to content

Commit

Permalink
Remove 'hls/playingLive' check when generating acl
Browse files Browse the repository at this point in the history
Like it is done on Pillarbox web and Apple.
  • Loading branch information
StaehliJ committed Aug 21, 2023
1 parent dd836cd commit b977e2e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AkamaiTokenProviderTest {

@Test
fun testInvalidUriForAcl() {
val uri = Uri.parse("https://host")
val uri = Uri.parse("https://www.fake.url")
val acl = AkamaiTokenProvider.getAcl(uri)
Assert.assertNull(acl)
}
Expand Down Expand Up @@ -57,7 +57,7 @@ class AkamaiTokenProviderTest {
@Test
fun testAclLive() {
val uri = Uri.parse("https://fake.url/content/hls/playingLive/additional/path")
val expectedAcl = "/hls/playingLive/*"
val expectedAcl = "/content/hls/playingLive/additional/*"
val acl = AkamaiTokenProvider.getAcl(uri)
Assert.assertNotNull(acl)
Assert.assertEquals(expectedAcl, acl)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package ch.srgssr.pillarbox.core.business.akamai

import android.net.Uri
import android.text.TextUtils
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import retrofit2.Retrofit
Expand Down Expand Up @@ -78,15 +77,10 @@ class AkamaiTokenProvider private constructor(private val tokenService: Service)

internal fun getAcl(uri: Uri): String? {
val path = uri.path
if (path == null || TextUtils.isEmpty(path)) {
if (path.isNullOrEmpty()) {
return null
}
return if (path.contains("/hls/playingLive/")) {
"/hls/playingLive/*"
} else {
/* replace "master.m3u8" by "*" */
path.substring(0, path.lastIndexOf("/") + 1) + "*"
}
return path.substring(0, path.lastIndexOf("/") + 1) + "*"
}

private fun createService(): Service {
Expand Down

0 comments on commit b977e2e

Please sign in to comment.