diff --git a/lib/views/layout.rb b/lib/views/layout.rb index c643d1d..bfc5f5c 100644 --- a/lib/views/layout.rb +++ b/lib/views/layout.rb @@ -88,7 +88,7 @@ module Pressa link(rel: "dns-prefetch", href: "https://gist.github.com") all_styles.each do |style| - link(rel: "stylesheet", type: "text/css", href: absolute_asset(style.href)) + link(rel: "stylesheet", type: "text/css", href: style_href(style.href)) end end @@ -191,6 +191,12 @@ module Pressa absolute_asset(src) end + def style_href(href) + return href if href.start_with?("http://", "https://") + + absolute_asset(href) + end + def absolute_asset(path) normalized = path.start_with?("/") ? path : "/#{path}" site.url_for(normalized) diff --git a/spec/views/layout_spec.rb b/spec/views/layout_spec.rb index d6417b6..741722f 100644 --- a/spec/views/layout_spec.rb +++ b/spec/views/layout_spec.rb @@ -44,4 +44,23 @@ RSpec.describe Pressa::Views::Layout do expect(html).to include("