Fix error when menu URL shorter than 4 characters is set

Fix the error when calling slicestr to slice out-of-range bounds

See #439
This commit is contained in:
Elton Chen-Yu Ho authored and gcushen committed 2018-01-08 19:07:40 +00:00
1 parent 0514bbd48d
commit a42037eadd
1 file changed
+7 -5
+7 -5
View File
@@ -51,11 +51,13 @@
</li>
{{ else }}
{{ if eq "http" (slicestr .URL 0 4) }}
{{ $.Scratch.Set "target" " target=\"_blank\" rel=\"noopener\"" }}
{{ else }}
{{ $.Scratch.Set "target" "" }}
{{/* Set target for link. */}}
{{ $.Scratch.Set "target" "" }}
{{ if gt (len .URL) 4 }}
{{ if eq "http" (slicestr .URL 0 4) }}
{{ $.Scratch.Set "target" " target=\"_blank\" rel=\"noopener\"" }}
{{ end }}
{{ end }}
<li class="nav-item">