Skip to content

Commit 6a149ae

Browse files
committed
ProductSelector: Normalize path for preview environments
1 parent 5365191 commit 6a149ae

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

layouts/partials/sidebar-v2.html

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

12-
{{ $relPermalink := (urls.Parse .RelPermalink).Path }}
12+
<!-- Normalize our URL path to handle preview environments -->
13+
{{ $rawPath := strings.TrimPrefix .Site.BaseURL .Permalink }}
14+
{{ $normalizedPath := printf "/%s" $rawPath }}
15+
1316
{{ $currentProductTitle := "" }}
1417

1518
{{ with index .Site.Data "product-selector" }}
@@ -18,7 +21,7 @@
1821
{{ if not $product.extUrl }}
1922
{{ $escaped := replace $product.url "/" "\\/" }}
2023
{{ $pattern := printf "/%s(|$)" $escaped }}
21-
{{ if strings.FindRE $pattern $relPermalink }}
24+
{{ if strings.FindRE $pattern $normalizedPath }}
2225
{{ $currentProductTitle = $product.title }}
2326
{{ end }}
2427
{{ end }}

0 commit comments

Comments
 (0)