Skip to content

Commit 7a15f6e

Browse files
authored
ProductSelector: Match product identifier exactly (#397)
* ProductSelector: Match product identifier exactly Resolve issues when a product ID is a subset of another * ProductSelector: Trim trailing/leading slashes in url identifier
1 parent 80dca4d commit 7a15f6e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

layouts/partials/sidebar-v2.html

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,13 @@
1919
{{ range $group := . }}
2020
{{ range $product := $group.products }}
2121
{{ if not $product.extUrl }}
22-
{{ $escaped := replace $product.url "/" "\\/" }}
23-
{{ $pattern := printf "/%s(|$)" $escaped }}
22+
<!-- Remove any leading or trailing slashes for capture group handling -->
23+
{{ $escaped := strings.TrimPrefix "/" $product.url }}
24+
{{ $escaped = strings.TrimSuffix "/" $escaped }}
25+
26+
{{ $escaped = replace $escaped "/" "\\/" }}
27+
{{ $pattern := printf "/(%s)/" $escaped }}
28+
2429
{{ if strings.FindRE $pattern $normalizedPath }}
2530
{{ $currentProductTitle = $product.title }}
2631
{{ end }}

0 commit comments

Comments
 (0)