Skip to content

Commit 8ff843d

Browse files
authored
ProductSelector: Normalize URL comparison for product (#375)
1 parent eed272c commit 8ff843d

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

layouts/partials/sidebar-v2.html

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,17 @@
99
</label>
1010
</div>
1111

12-
{{ $relPermalink := .RelPermalink }}
13-
{{ $productIdentifier := index ((split $relPermalink "/")) 1 }}
14-
{{ $relPermalink := strings.TrimSuffix "/" $productIdentifier }}
12+
{{ $relPermalink := .RelPermalink | strings.TrimPrefix "/" | strings.TrimSuffix "/" }}
1513
{{ $currentProductTitle := "" }}
1614

1715
{{ with index .Site.Data "product-selector" }}
1816
{{ range $group := . }}
1917
{{ range $product := $group.products }}
20-
{{ $splitProductUrl := index ((split $product.url "/")) 1 }}
21-
{{ $suffixProductUrl := strings.TrimSuffix "/" $splitProductUrl | }}
22-
{{ $prefixProductUrl := strings.TrimPrefix "/" $suffixProductUrl | }}
23-
{{ if (eq $prefixProductUrl $productIdentifier) }}
24-
{{ $currentProductTitle = $product.title }}
18+
{{ if not $product.extUrl }}
19+
{{ $productUrl := $product.url | strings.TrimPrefix "/" | strings.TrimSuffix "/" }}
20+
{{ if eq $productUrl $relPermalink }}
21+
{{ $currentProductTitle = $product.title }}
22+
{{ end }}
2523
{{ end }}
2624
{{ end }}
2725
{{ end }}

0 commit comments

Comments
 (0)