From 0f16e2b72cd233e8ae37ba5e89b9d191f3745ebd Mon Sep 17 00:00:00 2001 From: Cell <1024@lruihao.cn> Date: Fri, 20 May 2022 17:01:47 +0800 Subject: [PATCH] :zap: Perf: optimize path splicing (#139) --- layouts/partials/home/profile.html | 2 +- layouts/partials/single/footer.html | 2 +- layouts/partials/single/post-author.html | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/layouts/partials/home/profile.html b/layouts/partials/home/profile.html index 5af91364..d139b518 100644 --- a/layouts/partials/home/profile.html +++ b/layouts/partials/home/profile.html @@ -5,7 +5,7 @@ {{- $gravatar := .Site.Params.gravatar -}} {{- with $gravatar -}} {{- $avatar = printf "https://%v/avatar/%v?s=240&d=%v" - (.Host | default "www.gravatar.com") + (path.Clean .Host | default "www.gravatar.com") (md5 $profile.gravatarEmail) (.Style | default "mp") -}} diff --git a/layouts/partials/single/footer.html b/layouts/partials/single/footer.html index 3568abd1..1d62b772 100644 --- a/layouts/partials/single/footer.html +++ b/layouts/partials/single/footer.html @@ -38,7 +38,7 @@ {{- with $params.edit -}} {{- if .Enable -}} - {{- $options := dict "Class" "link-to-edit" "Destination" (printf "%v/%v" .Url $.File.Path) "Title" (T "editThisPage") "Content" (T "editThisPage") "externalIcon" false -}} + {{- $options := dict "Class" "link-to-edit" "Destination" (path.Join .Url $.File.Path) "Title" (T "editThisPage") "Content" (T "editThisPage") "externalIcon" false -}} {{- partial "plugin/link.html" $options -}} {{- end -}} diff --git a/layouts/partials/single/post-author.html b/layouts/partials/single/post-author.html index 58e5eed9..8b0b9c81 100644 --- a/layouts/partials/single/post-author.html +++ b/layouts/partials/single/post-author.html @@ -11,7 +11,11 @@ {{- if (not $avatar | or $params.gravatarForce) | and $author.email -}} {{- $gravatar := .Site.Params.gravatar -}} {{- with $gravatar -}} - {{- $avatar = printf "https://%v/avatar/%v?s=32&d=%v" (.Host | default "www.gravatar.com") (md5 $author.email) (.Style | default "") -}} + {{- $avatar = printf "https://%v/avatar/%v?s=32&d=%v" + (path.Clean .Host | default "www.gravatar.com") + (md5 $author.email) + (.Style | default "") + -}} {{- end -}} {{- end -}}