Add rewrite_ignore option to asset_host, cache_buster, relative_assets.
This commit is contained in:
parent
0563523a81
commit
37be89ed68
|
@ -35,3 +35,17 @@ Feature: Alternate between multiple asset hosts
|
||||||
When I go to "/stylesheets/asset_host.css"
|
When I go to "/stylesheets/asset_host.css"
|
||||||
Then I should see content matching %r{http://assets1.example.com/}
|
Then I should see content matching %r{http://assets1.example.com/}
|
||||||
Then I should not see content matching %r{http://assets1.example.com//}
|
Then I should not see content matching %r{http://assets1.example.com//}
|
||||||
|
|
||||||
|
Scenario: Hosts are not rewritten for rewrite ignored paths
|
||||||
|
Given a fixture app "asset-host-app"
|
||||||
|
And a file named "config.rb" with:
|
||||||
|
"""
|
||||||
|
activate :asset_host, host: "http://assets1.example.com", rewrite_ignore: [
|
||||||
|
'/stylesheets/asset_host.css',
|
||||||
|
]
|
||||||
|
"""
|
||||||
|
And the Server is running
|
||||||
|
When I go to "/asset_host.html"
|
||||||
|
Then I should see content matching %r{http://assets1.example.com/}
|
||||||
|
When I go to "/stylesheets/asset_host.css"
|
||||||
|
Then I should not see content matching %r{http://assets1.example.com/}
|
||||||
|
|
|
@ -40,3 +40,17 @@ Feature: Generate mtime-based query string for busting browser caches
|
||||||
When I go to "/cache-buster.html"
|
When I go to "/cache-buster.html"
|
||||||
Then I should see "site.css?"
|
Then I should see "site.css?"
|
||||||
Then I should see "blank.gif?"
|
Then I should see "blank.gif?"
|
||||||
|
|
||||||
|
Scenario: URLs are not rewritten for rewrite ignored paths
|
||||||
|
Given a fixture app "cache-buster-app"
|
||||||
|
And a file named "config.rb" with:
|
||||||
|
"""
|
||||||
|
activate :cache_buster, rewrite_ignore: [
|
||||||
|
'/cache-buster.html',
|
||||||
|
]
|
||||||
|
"""
|
||||||
|
And the Server is running at "cache-buster-app"
|
||||||
|
When I go to "/cache-buster.html"
|
||||||
|
Then I should see 'site.css"'
|
||||||
|
Then I should see 'empty-with-include.js"'
|
||||||
|
Then I should see 'blank.gif"'
|
||||||
|
|
|
@ -132,3 +132,17 @@ Feature: Relative Assets
|
||||||
And the Server is running at "relative-assets-app"
|
And the Server is running at "relative-assets-app"
|
||||||
When I go to "/sub/image_tag.html"
|
When I go to "/sub/image_tag.html"
|
||||||
Then I should see '<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" />'
|
Then I should see '<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" />'
|
||||||
|
|
||||||
|
Scenario: URLs are not rewritten for rewrite ignored paths
|
||||||
|
Given a fixture app "relative-assets-app"
|
||||||
|
And a file named "config.rb" with:
|
||||||
|
"""
|
||||||
|
activate :relative_assets, rewrite_ignore: [
|
||||||
|
'/stylesheets/fonts.css',
|
||||||
|
]
|
||||||
|
"""
|
||||||
|
And the Server is running at "relative-assets-app"
|
||||||
|
When I go to "/stylesheets/relative_assets.css"
|
||||||
|
Then I should see 'url("../images/blank.gif'
|
||||||
|
When I go to "/stylesheets/fonts.css"
|
||||||
|
Then I should see 'url(/fonts/roboto/roboto-regular-webfont.eot'
|
||||||
|
|
|
@ -6,6 +6,7 @@ class Middleman::Extensions::AssetHost < ::Middleman::Extension
|
||||||
option :exts, %w(.css .png .jpg .jpeg .webp .svg .svgz .js .gif), 'List of extensions that get cache busters strings appended to them.'
|
option :exts, %w(.css .png .jpg .jpeg .webp .svg .svgz .js .gif), 'List of extensions that get cache busters strings appended to them.'
|
||||||
option :sources, %w(.htm .html .php .css .js), 'List of extensions that are searched for bustable assets.'
|
option :sources, %w(.htm .html .php .css .js), 'List of extensions that are searched for bustable assets.'
|
||||||
option :ignore, [], 'Regexes of filenames to skip adding query strings to'
|
option :ignore, [], 'Regexes of filenames to skip adding query strings to'
|
||||||
|
option :rewrite_ignore, [], 'Regexes of filenames to skip processing for host rewrites'
|
||||||
|
|
||||||
def ready
|
def ready
|
||||||
app.use ::Middleman::Middleware::InlineURLRewriter,
|
app.use ::Middleman::Middleware::InlineURLRewriter,
|
||||||
|
@ -13,6 +14,7 @@ class Middleman::Extensions::AssetHost < ::Middleman::Extension
|
||||||
url_extensions: options.exts,
|
url_extensions: options.exts,
|
||||||
source_extensions: options.sources,
|
source_extensions: options.sources,
|
||||||
ignore: options.ignore,
|
ignore: options.ignore,
|
||||||
|
rewrite_ignore: options.rewrite_ignore,
|
||||||
middleman_app: app,
|
middleman_app: app,
|
||||||
proc: method(:rewrite_url)
|
proc: method(:rewrite_url)
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,6 +3,7 @@ class Middleman::Extensions::CacheBuster < ::Middleman::Extension
|
||||||
option :exts, %w(.css .png .jpg .jpeg .webp .svg .svgz .js .gif), 'List of extensions that get cache busters strings appended to them.'
|
option :exts, %w(.css .png .jpg .jpeg .webp .svg .svgz .js .gif), 'List of extensions that get cache busters strings appended to them.'
|
||||||
option :sources, %w(.htm .html .php .css .js), 'List of extensions that are searched for bustable assets.'
|
option :sources, %w(.htm .html .php .css .js), 'List of extensions that are searched for bustable assets.'
|
||||||
option :ignore, [], 'Regexes of filenames to skip adding query strings to'
|
option :ignore, [], 'Regexes of filenames to skip adding query strings to'
|
||||||
|
option :rewrite_ignore, [], 'Regexes of filenames to skip processing for path rewrites'
|
||||||
|
|
||||||
def initialize(app, options_hash={}, &block)
|
def initialize(app, options_hash={}, &block)
|
||||||
super
|
super
|
||||||
|
@ -16,6 +17,7 @@ class Middleman::Extensions::CacheBuster < ::Middleman::Extension
|
||||||
url_extensions: options.exts,
|
url_extensions: options.exts,
|
||||||
source_extensions: options.sources,
|
source_extensions: options.sources,
|
||||||
ignore: options.ignore,
|
ignore: options.ignore,
|
||||||
|
rewrite_ignore: options.rewrite_ignore,
|
||||||
middleman_app: app,
|
middleman_app: app,
|
||||||
proc: method(:rewrite_url)
|
proc: method(:rewrite_url)
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,6 +5,7 @@ class Middleman::Extensions::RelativeAssets < ::Middleman::Extension
|
||||||
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 :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 :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'
|
option :ignore, [], 'Regexes of filenames to skip adding query strings to'
|
||||||
|
option :rewrite_ignore, [], 'Regexes of filenames to skip processing for path rewrites'
|
||||||
|
|
||||||
def initialize(app, options_hash={}, &block)
|
def initialize(app, options_hash={}, &block)
|
||||||
super
|
super
|
||||||
|
@ -18,6 +19,7 @@ class Middleman::Extensions::RelativeAssets < ::Middleman::Extension
|
||||||
url_extensions: options.exts,
|
url_extensions: options.exts,
|
||||||
source_extensions: options.sources,
|
source_extensions: options.sources,
|
||||||
ignore: options.ignore,
|
ignore: options.ignore,
|
||||||
|
rewrite_ignore: options.rewrite_ignore,
|
||||||
middleman_app: app,
|
middleman_app: app,
|
||||||
proc: method(:rewrite_url)
|
proc: method(:rewrite_url)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue