Skip to content

Commit

Permalink
feat: ignore suffix slash of video host
Browse files Browse the repository at this point in the history
  • Loading branch information
reuixiy committed Nov 29, 2021
1 parent d8af0e0 commit 597d20d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions layouts/partials/utils/content.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
Expand Down

0 comments on commit 597d20d

Please sign in to comment.