refactor(android): add shared albumCoverPath cover-URL builder
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
package com.fabledsword.minstrel.models
|
||||
|
||||
/**
|
||||
* Absolute cover URL for an album, or "" when [albumId] is blank. Uses
|
||||
* the placeholder host that `BaseUrlInterceptor` rewrites to the live
|
||||
* server (carrying the auth cookie); `ServerImage` passes it through,
|
||||
* and the raw-AsyncImage cover surfaces still load it. The single
|
||||
* album-cover URL builder for the whole client.
|
||||
*/
|
||||
fun albumCoverPath(albumId: String): String =
|
||||
if (albumId.isEmpty()) "" else "http://placeholder.invalid/api/albums/$albumId/cover"
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.fabledsword.minstrel.models
|
||||
|
||||
import org.junit.jupiter.api.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class CoverUrlsTest {
|
||||
@Test
|
||||
fun `albumCoverPath builds the placeholder cover URL`() {
|
||||
assertEquals("http://placeholder.invalid/api/albums/a1/cover", albumCoverPath("a1"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `albumCoverPath is empty for a blank id`() {
|
||||
assertEquals("", albumCoverPath(""))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user