diff options
author | reuixiy <reuixiy@gmail.com> | 2021-11-29 19:25:28 +0300 |
---|---|---|
committer | reuixiy <reuixiy@gmail.com> | 2021-11-29 19:25:28 +0300 |
commit | 597d20db75e696f75a1c4e30a0791aa3a5266478 (patch) | |
tree | e95e066f8814b16dccb27f17176bbd97d0cce283 | |
parent | d8af0e0d6c89afc4cc79982cb73a8c094cf5ee5e (diff) |
feat: ignore suffix slash of video host
-rw-r--r-- | layouts/partials/utils/content.html | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/layouts/partials/utils/content.html b/layouts/partials/utils/content.html index 05ec4c4..1adcd85 100644 --- a/layouts/partials/utils/content.html +++ b/layouts/partials/utils/content.html @@ -129,14 +129,14 @@ <!-- Video Hosting --> {{- if and .Site.Params.enableVideoHost (eq hugo.Environment "production") -}} - {{- $hostURL := .Site.Params.videoHostURL -}} + {{- $hostURL := strings.TrimSuffix "/" .Site.Params.videoHostURL -}} {{- $temps := findRE `<(video) src="/?([^":]+)` $Content | uniq -}} {{- with $temps -}} {{- range . -}} {{- if not (in (slice "http" "ttps") (substr . -1 4)) -}} {{- $url := replaceRE `<(video) src="/?([^":]+)` `$2` . -}} {{- $prefix := replaceRE `(<(video) src=")/?([^":]+)` `$1` . -}} - {{- $replacement := (printf `%s%s%s` $prefix $hostURL $url) -}} + {{- $replacement := (printf `%s%s/%s` $prefix $hostURL $url) -}} {{- $Content = replace $Content . $replacement -}} {{- end -}} {{- end -}} |