1
0
Fork 0
mirror of https://github.com/middleman/middleman.git synced 2022-11-09 12:20:27 -05:00

Change inline URL matcher to only match strings, not newlines. Fixes #1689

This commit is contained in:
Thomas Reynolds 2015-12-13 13:06:05 -08:00
parent d3a5494062
commit 76f591788e
9 changed files with 24 additions and 3 deletions

View file

@ -36,6 +36,11 @@ Feature: Relative Assets
Then I should see 'url("../images/blank.gif'
When I go to "/javascripts/application.js"
Then I should not see "../"
When I go to "/stylesheets/fonts.css"
Then I should see 'url(../fonts/roboto/roboto-regular-webfont.eot'
And I should see 'url(../fonts/roboto/roboto-regular-webfont.woff'
And I should see 'url(../fonts/roboto/roboto-regular-webfont.ttf'
And I should see 'url(../fonts/roboto/roboto-regular-webfont.svg'
Scenario: Building css with the feature enabled
Given a fixture app "relative-assets-app"

View file

@ -1 +1,5 @@
# activate :relative_assets
set :fonts_dir, 'fonts'
configure :build do
activate :relative_assets
end

View file

@ -0,0 +1,10 @@
@font-face {
font-family: 'Roboto';
src: url(/fonts/roboto/roboto-regular-webfont.eot);
src: url(/fonts/roboto/roboto-regular-webfont.eot?#iefix) format('embedded-opentype'),
url(/fonts/roboto/roboto-regular-webfont.woff) format('woff'),
url(/fonts/roboto/roboto-regular-webfont.ttf) format('truetype'),
url(/fonts/roboto/roboto-regular-webfont.svg#robotoregular) format('svg');
font-weight: normal;
font-style: normal;
}

View file

@ -2,7 +2,7 @@ require 'addressable/uri'
# Relative Assets extension
class Middleman::Extensions::RelativeAssets < ::Middleman::Extension
option :exts, %w(.css .png .jpg .jpeg .webp .svg .svgz .js .gif .ttf .otf .woff .woff2), 'List of extensions that get cache busters strings appended to them.'
option :exts, %w(.css .png .jpg .jpeg .webp .svg .svgz .js .gif .ttf .otf .woff .woff2 .eot), 'List of extensions that get cache busters strings appended to them.'
option :sources, %w(.htm .html .css), 'List of extensions that are searched for relative assets.'
option :ignore, [], 'Regexes of filenames to skip adding query strings to'

View file

@ -332,7 +332,9 @@ module Middleman
Contract String, String, ArrayOf[String], Proc => String
def rewrite_paths(body, _path, exts, &_block)
body.dup.gsub(/([=\'\"\(,]\s*)([^\s\'\"\)>]+(#{Regexp.union(exts)}))/) do |match|
matcher = /([=\'\"\(,] *)([^\s\'\"\)>]+(#{Regexp.union(exts)}))/
body.dup.gsub(matcher) do |match|
opening_character = $1
asset_path = $2