1

Affiche le domaine des attributions URL

This commit is contained in:
2026-03-23 23:24:13 +01:00
parent 73f3b58003
commit 8b6e69a025
6 changed files with 31 additions and 5 deletions

View File

@@ -0,0 +1,19 @@
{{- $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 -}}