Skip to content

Commit a11a0a1

Browse files
committed
ProductSelector: Trim trailing/leading slashes in url identifier
1 parent 4a8bfb9 commit a11a0a1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

layouts/partials/sidebar-v2.html

Lines changed: 6 additions & 1 deletion
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 "/" "\\/" }}
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 "/" "\\/" }}
2327
{{ $pattern := printf "/(%s)/" $escaped }}
28+
2429
{{ if strings.FindRE $pattern $normalizedPath }}
2530
{{ $currentProductTitle = $product.title }}
2631
{{ end }}

0 commit comments

Comments
 (0)