module Capybara::Helpers
def inject_asset_host(html, host: Capybara.asset_host)
-
(String)- The modified HTML code
Parameters:
-
host(URL) -- (Capybara.asset_host) The host from which assets should be loaded -
html(String) -- HTML code to inject into
def inject_asset_host(html, host: Capybara.asset_host) if host && Nokogiri::HTML(html).css("base").empty? match = html.match(/<head[^<]*?>/) return html.clone.insert match.end(0), "<base href='#{host}' />" if match end html end