Skip to content

Commit

Permalink
fix: getImageUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
VaiTon committed Mar 18, 2023
1 parent 1e49f85 commit 2626919
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Expand Up @@ -63,11 +63,11 @@ fun getImageUrl(barcode: Barcode, imageName: String, size: String): String {
else buildString {
append(rawBarcode.substring(0, 3))
append("/")
append(rawBarcode.substring(3, 7))
append(rawBarcode.substring(3, 6))
append("/")
append(rawBarcode.substring(7, 11))
append(rawBarcode.substring(6, 9))
append("/")
append(rawBarcode.substring(11))
append(rawBarcode.substring(9))
}

return "$BASE_IMAGES_URL/$barcodePattern/$imageName.$size.jpg"
Expand Down
Expand Up @@ -5,6 +5,7 @@ import io.mockk.every
import io.mockk.impl.annotations.MockK
import io.mockk.junit5.MockKExtension
import openfoodfacts.github.scrachx.openfood.BuildConfig
import openfoodfacts.github.scrachx.openfood.models.Barcode
import openfoodfacts.github.scrachx.openfood.models.Product
import openfoodfacts.github.scrachx.openfood.models.ProductImageField
import org.junit.jupiter.api.Test
Expand Down Expand Up @@ -34,7 +35,7 @@ class ImageKeyHelperTest {

@Test
fun imageUrl_BarcodeShorter() {
val barcode = "303371"
val barcode = Barcode("303371")
val imageName = "123"
val size = "987"
val expected = BuildConfig.STATICURL + "/images/products/303371/123.987.jpg"
Expand All @@ -43,7 +44,7 @@ class ImageKeyHelperTest {

@Test
fun imageUrl_BarcodeLonger() {
val barcode = "3033710001279"
val barcode = Barcode("3033710001279")
val imageName = "123"
val size = "987"
val expected = BuildConfig.STATICURL + "/images/products/303/371/000/1279/123.987.jpg"
Expand Down

0 comments on commit 2626919

Please sign in to comment.