Skip to content

Commit ca6be51

Browse files
authored
Merge pull request #379 from nginxinc/product-selector-bug
ProductSelector: Regex match paths
2 parents f5abced + af00098 commit ca6be51

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

layouts/partials/sidebar-v2.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@
99
</label>
1010
</div>
1111

12-
{{ $relPermalink := .RelPermalink }}
12+
{{ $relPermalink := (urls.Parse .RelPermalink).Path }}
1313
{{ $currentProductTitle := "" }}
1414

1515
{{ with index .Site.Data "product-selector" }}
1616
{{ range $group := . }}
1717
{{ range $product := $group.products }}
1818
{{ if not $product.extUrl }}
19-
{{ warnf "$relPermalink: %s" $relPermalink }}
20-
{{ warnf "$product.url: %s" $product.url }}
21-
{{ if strings.Contains $relPermalink $product.url }}
19+
{{ $escaped := replace $product.url "/" "\\/" }}
20+
{{ $pattern := printf "/%s(/|$)" $escaped }}
21+
{{ if strings.FindRE $pattern $relPermalink }}
2222
{{ $currentProductTitle = $product.title }}
2323
{{ end }}
2424
{{ end }}
@@ -27,6 +27,7 @@
2727
{{ end }}
2828

2929

30+
3031
<div class="product-selector">
3132
<details class="product-selector__section">
3233
<summary class="product-selector__toggle">

0 commit comments

Comments
 (0)