From 74c2bd2fa86bf59d338453d4af6d87ceecf9ee29 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 13 May 2026 10:21:59 +0000 Subject: [PATCH] test(blossom-bridge): inline the share.yabu.me URL literally Building the URL from extracted prefix/blob constants could mask a parser bug that splits the path the same way the test constructs it. Use the full URL from the bug report as a single literal so the test only agrees with the parser if the parser actually parses the URL correctly. --- ...ocalBlossomCacheRedirectInterceptorTest.kt | 12 +++++++---- .../richtext/MediaUrlContentExtTest.kt | 20 ++++++++++--------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/amethyst/src/test/java/com/vitorpamplona/amethyst/service/okhttp/LocalBlossomCacheRedirectInterceptorTest.kt b/amethyst/src/test/java/com/vitorpamplona/amethyst/service/okhttp/LocalBlossomCacheRedirectInterceptorTest.kt index 489b1b241..f17c0bea4 100644 --- a/amethyst/src/test/java/com/vitorpamplona/amethyst/service/okhttp/LocalBlossomCacheRedirectInterceptorTest.kt +++ b/amethyst/src/test/java/com/vitorpamplona/amethyst/service/okhttp/LocalBlossomCacheRedirectInterceptorTest.kt @@ -135,13 +135,17 @@ class LocalBlossomCacheRedirectInterceptorTest { @Test fun bridgeOnPicksRightmostShaWhenPathHasTwoHashes() { // share.yabu.me layout: /. - val prefix = "84b0c46ab699ac35eb2ca286470b85e081db2087cdef63932236c397417782f5" - val blob = "28fa4d999af6ae3e4e11bfc2727130ef1b3a13cc0f981e5a93c3996cb2f524e5" val interceptor = LocalBlossomCacheRedirectInterceptor { true } val captured = mutableListOf() - val response = interceptor.intercept(fakeChain("https://share.yabu.me/$prefix/$blob.webp", captured)) + val response = + interceptor.intercept( + fakeChain( + "https://share.yabu.me/84b0c46ab699ac35eb2ca286470b85e081db2087cdef63932236c397417782f5/28fa4d999af6ae3e4e11bfc2727130ef1b3a13cc0f981e5a93c3996cb2f524e5.webp", + captured, + ), + ) assertEquals( - "http://127.0.0.1:24242/$blob.webp?xs=https%3A%2F%2Fshare.yabu.me%2F$prefix", + "http://127.0.0.1:24242/28fa4d999af6ae3e4e11bfc2727130ef1b3a13cc0f981e5a93c3996cb2f524e5.webp?xs=https%3A%2F%2Fshare.yabu.me%2F84b0c46ab699ac35eb2ca286470b85e081db2087cdef63932236c397417782f5", captured.single(), ) response.close() diff --git a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/richtext/MediaUrlContentExtTest.kt b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/richtext/MediaUrlContentExtTest.kt index 853dad9b5..ee7d28e7b 100644 --- a/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/richtext/MediaUrlContentExtTest.kt +++ b/commons/src/commonTest/kotlin/com/vitorpamplona/amethyst/commons/richtext/MediaUrlContentExtTest.kt @@ -177,23 +177,25 @@ class MediaUrlContentExtTest { @Test fun bridgeOnPicksRightmostShaWhenPathHasTwoHashes() { // share.yabu.me layout: /. - val prefix = "84b0c46ab699ac35eb2ca286470b85e081db2087cdef63932236c397417782f5" - val blob = "28fa4d999af6ae3e4e11bfc2727130ef1b3a13cc0f981e5a93c3996cb2f524e5" - val image = MediaUrlImage(url = "https://share.yabu.me/$prefix/$blob.webp", hash = null) + val image = + MediaUrlImage( + url = "https://share.yabu.me/84b0c46ab699ac35eb2ca286470b85e081db2087cdef63932236c397417782f5/28fa4d999af6ae3e4e11bfc2727130ef1b3a13cc0f981e5a93c3996cb2f524e5.webp", + hash = null, + ) assertEquals( - "blossom:$blob.webp?xs=https://share.yabu.me/$prefix", + "blossom:28fa4d999af6ae3e4e11bfc2727130ef1b3a13cc0f981e5a93c3996cb2f524e5.webp?xs=https://share.yabu.me/84b0c46ab699ac35eb2ca286470b85e081db2087cdef63932236c397417782f5", image.toCoilModel(useLocalBlossomBridge = true), ) } @Test fun bridgeProfilePictureUrlPicksRightmostShaWhenPathHasTwoHashes() { - val prefix = "84b0c46ab699ac35eb2ca286470b85e081db2087cdef63932236c397417782f5" - val blob = "28fa4d999af6ae3e4e11bfc2727130ef1b3a13cc0f981e5a93c3996cb2f524e5" - val url = "https://share.yabu.me/$prefix/$blob.webp" assertEquals( - "http://127.0.0.1:24242/$blob.webp?xs=https%3A%2F%2Fshare.yabu.me%2F$prefix", - bridgeProfilePictureUrl(url, useBridge = true), + "http://127.0.0.1:24242/28fa4d999af6ae3e4e11bfc2727130ef1b3a13cc0f981e5a93c3996cb2f524e5.webp?xs=https%3A%2F%2Fshare.yabu.me%2F84b0c46ab699ac35eb2ca286470b85e081db2087cdef63932236c397417782f5", + bridgeProfilePictureUrl( + "https://share.yabu.me/84b0c46ab699ac35eb2ca286470b85e081db2087cdef63932236c397417782f5/28fa4d999af6ae3e4e11bfc2727130ef1b3a13cc0f981e5a93c3996cb2f524e5.webp", + useBridge = true, + ), ) } }