Permalink
Browse files

Merge pull request #6 from dmnelson/master

Change on the file extension regex
  • Loading branch information...
2 parents 99dca1b + 8365170 commit 0d482e421eefd29802dbbf3248dd4db501e59bef @adaoraul committed Aug 8, 2012
Showing with 10 additions and 4 deletions.
  1. +2 −2 lib/rack/jekyll/helpers.rb
  2. +2 −2 lib/rack/jekyll/test.rb
  3. +5 −0 spec/spec_rack-jekyll.rb
  4. +1 −0 test/rack-jekyll.rb
@@ -2,7 +2,7 @@ module Rack
class Jekyll
def mime(path_info)
if path_info !~ /html$/i
- ext = $1 if path_info =~ /(\.\S+)$/
+ ext = $1 if path_info =~ /(\.[\S&&[^.]]+)$/
Mime.mime_type((ext.nil? ? ".html" : ext))
else
Mime.mime_type(".html")
@@ -16,4 +16,4 @@ def file_info(path)
end
end
end
-end
+end
View
@@ -7,7 +7,7 @@ module Rack
class Jekyll
class Test
def initialize
- @files = %w{_fake/ _fake/index.html _fake/3/2/1/helloworld/index.html _fake/css/test.css _fake/js/test.js}
+ @files = %w{_fake/ _fake/index.html _fake/3/2/1/helloworld/index.html _fake/css/test.css _fake/js/test.js _fake/js/test.min.js}
@mimes = Rack::Mime::MIME_TYPES.reject{|k,v|k=~%r{html?}}.map{|k,v|%r{#{k.gsub('.','\.')}$}i}
end
@@ -35,7 +35,7 @@ def call(env)
end
end
def mime(path_info)
- ext = $1 if path_info =~ /(\.\S+)$/
+ ext = $1 if path_info =~ /(\.[\S&&[^.]]+)$/
Mime.mime_type((ext.nil? ? ".html" : ext))
end
end
View
@@ -48,6 +48,11 @@ def get(klass, path)
res = get(jekyll,"/js/test.js")
res.headers["Content-Type"].should.equal "application/javascript"
end
+
+ it "should be application/javascript even when minified" do
+ res = get(jekyll,"/js/test.min.js")
+ res.headers["Content-Type"].should.equal "application/javascript"
+ end
end
View
@@ -26,6 +26,7 @@ def test_content_types
assert_equal(@request.get("/").headers["Content-Type"],"text/html")
assert_equal(@request.get("/css/test.css").headers["Content-Type"],"text/css")
assert_equal(@request.get("/js/test.js").headers["Content-Type"],"application/javascript")
+ assert_equal(@request.get("/js/test.min.js").headers["Content-Type"],"application/javascript")
end
def test_content_length

0 comments on commit 0d482e4

Please sign in to comment.