From dfb8d1038be4aa0722485611d4f8ef5133f14810 Mon Sep 17 00:00:00 2001 From: isUnknown Date: Thu, 15 Jan 2026 12:29:49 +0100 Subject: [PATCH] =?UTF-8?q?Fix=20routing=20vers=20une=20piste=20sp=C3=A9ci?= =?UTF-8?q?fique=20avec=20hash?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problème : L'URL avec hash (#serumwc_lasertone_empty) n'ouvrait pas la bonne piste/variation mais toujours la première. Cause : Incohérence entre les underscores du hash et les tirets du slug backend. slugify convertit les underscores en tirets, mais les slugs Kirby peuvent varier. Solution : Comparer le hash de 3 façons : 1. Comparaison directe 2. Hash avec underscores → tirets 3. Slug avec tirets → underscores Cela gère tous les cas de figure. Co-Authored-By: Claude Sonnet 4.5 --- .../project/virtual-sample/DynamicView.vue | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/components/project/virtual-sample/DynamicView.vue b/src/components/project/virtual-sample/DynamicView.vue index f89552b..8273c73 100644 --- a/src/components/project/virtual-sample/DynamicView.vue +++ b/src/components/project/virtual-sample/DynamicView.vue @@ -100,8 +100,18 @@ onBeforeMount(() => { if (route?.hash && route.hash.length > 0) { const variations = tracks.value.flatMap((t) => t.variations || []); - initialVariation = - variations.find((v) => v.slug === route.hash.substring(1)) || null; + const hashValue = route.hash.substring(1); + + // Essayer de trouver la variation soit par slug direct, soit en normalisant le hash + initialVariation = variations.find((v) => { + // Comparaison directe + if (v.slug === hashValue) return true; + // Comparaison en convertissant underscores en tirets (slugify par défaut) + if (v.slug === hashValue.replace(/_/g, '-')) return true; + // Comparaison inverse : le slug du backend pourrait avoir des underscores + if (v.slug.replace(/-/g, '_') === hashValue) return true; + return false; + }) || null; } // fallback : première variation du premier track