Skip to content

Commit 369d4b3

Browse files
committed
refactor: Use util get-abs-url
1 parent a43edcb commit 369d4b3

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

hugo-modules/core/utils/asset/image/img.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@
5555
{{- end -}}
5656
{{- else -}}
5757
{{- with $url -}}
58-
{{- $src := $params.src | default (cond (hasPrefix . "//") (print "https:" .) .) -}}
58+
{{- $absUrl := partial "utils/get-abs-url" . -}}
59+
{{- $src := $params.src | default $absUrl -}}
5960
<img src="{{- $src -}}" width="{{- $width -}}" height="{{- $height -}}" {{ $image_attributes }} alt="{{- $alt -}}"{{ with $params.preload }} fetchpriority="high"{{ end }}>
6061
{{/* Add preload hint here as we have no srcset available */}}
6162
{{- $preload_attr := (dict

hugo-modules/core/utils/link.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
{{/* context is url */}}
1111
{{ if partialCached "utils/reflect/is-string" . . }}
12-
{{ $href := cond (and (hasPrefix . "//") (not (hasPrefix . "//localhost")) ) (print "https:" . ) . }}
12+
{{ $href := partial "utils/get-abs-url" . }}
1313
{{ $return = (dict "href" $href) }}
1414
{{/* Add target="_blank" and rel="noreferrer" for external links */}}
1515
{{ if (and (in . "//") (not (in . site.BaseURL))) }}

hugo-modules/core/utils/svg/parse.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
{{ end }}
5555
{{ end }}
5656
{{ with .url }}
57-
{{ $src = cond (hasPrefix . "//") (print "https:" .) . }}
57+
{{ $src := partial "utils/get-abs-url" . }}
5858
{{ with resources.GetRemote $src }}
5959
{{ $src = .RelPermalink }}
6060
{{ $source = .Content }}

0 commit comments

Comments
 (0)