1
Files
2025/themes/2026/layouts/_partials/media/parse-attribution.html

20 lines
473 B
HTML

{{- $raw := printf "%v" . -}}
{{- $trimmed := strings.TrimSpace $raw -}}
{{- $result := dict
"isURL" false
"label" ""
"url" ""
-}}
{{- if gt (len (findRE `(?i)^https?://[^[:space:]]+$` $trimmed)) 0 -}}
{{- $parsedURL := urls.Parse $trimmed -}}
{{- $host := replaceRE `:\d+$` "" $parsedURL.Host -}}
{{- if ne $host "" -}}
{{- $result = dict
"isURL" true
"label" $host
"url" $trimmed
-}}
{{- end -}}
{{- end -}}
{{- return $result -}}