mirror of
https://github.com/by-jp/www.byjp.me.git
synced 2025-08-09 01:35:56 +01:00
Prevent treating files starting with http as external links
This commit is contained in:
parent
6a84655f46
commit
19ab7f85e0
1 changed files with 1 additions and 1 deletions
|
@ -1,6 +1,6 @@
|
||||||
{{- $url := .url -}}
|
{{- $url := .url -}}
|
||||||
{{- $title := .Title -}}
|
{{- $title := .Title -}}
|
||||||
{{- $isExternal := strings.HasPrefix $url "http" -}}
|
{{- $isExternal := or (strings.HasPrefix $url "https://") (strings.HasPrefix $url "http://") -}}
|
||||||
{{- $text := .Text | default $url -}}
|
{{- $text := .Text | default $url -}}
|
||||||
{{/* It pains me that Hugo doesn't have a urls.IsValid method, and has no error catching to allow me to try urls.Parse and catch failures */}}
|
{{/* It pains me that Hugo doesn't have a urls.IsValid method, and has no error catching to allow me to try urls.Parse and catch failures */}}
|
||||||
{{- if gt (len (strings.FindRE `^https?:\/\/[A-z0-9_-]*?[:]?[A-z0-9_-]*?[@]?[A-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$` $text)) 0 -}}
|
{{- if gt (len (strings.FindRE `^https?:\/\/[A-z0-9_-]*?[:]?[A-z0-9_-]*?[@]?[A-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$` $text)) 0 -}}
|
||||||
|
|
Loading…
Reference in a new issue