From 3e18e165e0dbc10ea1e81c745a04ea7ae82c6e47 Mon Sep 17 00:00:00 2001 From: Jimmy Cai Date: Thu, 10 Sep 2020 23:24:19 +0200 Subject: [PATCH] feat(helper/image): better detection of external image By using strings.HasPrefix, it matches any images which name starts with http --- layouts/partials/helper/image.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/layouts/partials/helper/image.html b/layouts/partials/helper/image.html index 4136e67..c8371b4 100644 --- a/layouts/partials/helper/image.html +++ b/layouts/partials/helper/image.html @@ -4,7 +4,8 @@ {{ $result = merge $result (dict "exists" true) }} - {{ if strings.HasPrefix $imageField "http" }} + {{ $url := urls.Parse $imageField }} + {{ if or (eq $url.Scheme "http") (eq $url.Scheme "https") }} {{ $result = merge $result (dict "src" $imageField) }} {{ else }}