diff --git a/lib/jekyll/polyglot/patches/jekyll/site.rb b/lib/jekyll/polyglot/patches/jekyll/site.rb index c1a30688f..de7576723 100644 --- a/lib/jekyll/polyglot/patches/jekyll/site.rb +++ b/lib/jekyll/polyglot/patches/jekyll/site.rb @@ -213,26 +213,30 @@ def absolute_url_regex(url, disabled = false) def relativize_urls(doc, regex) return if doc.output.nil? - - doc.output.gsub!(regex, "href=\"#{@baseurl}/#{@active_lang}/" + '\1"') + modified_output = doc.output.dup + modified_output.gsub!(regex, "href=\"#{@baseurl}/#{@active_lang}/" + '\1"') + doc.output = modified_output end def relativize_absolute_urls(doc, regex, url) return if doc.output.nil? - - doc.output.gsub!(regex, "href=\"#{url}#{@baseurl}/#{@active_lang}/" + '\1"') + modified_output = doc.output.dup + modified_output.gsub!(regex, "href=\"#{url}#{@baseurl}/#{@active_lang}/" + '\1"') + doc.output = modified_output end def correct_nonrelativized_absolute_urls(doc, regex, url) return if doc.output.nil? - - doc.output.gsub!(regex, "href=\"#{url}#{@baseurl}/" + '\1"') + modified_output = doc.output.dup + modified_output.gsub!(regex, "href=\"#{url}#{@baseurl}/" + '\1"') + doc.output = modified_output end def correct_nonrelativized_urls(doc, regex) return if doc.output.nil? - - doc.output.gsub!(regex, "href=\"#{@baseurl}/" + '\1"') + modified_output = doc.output.dup + modified_output.gsub!(regex, "href=\"#{@baseurl}/" + '\1"') + doc.output = modified_output end end end