Permalink
Browse files

downcase middleware will not mess up with your non-precompiled assets!

  • Loading branch information...
1 parent 42d7c11 commit 72cc48d327fc3d05489ccc7e6fc673a0d93b60e2 @vvgomes vvgomes committed Dec 13, 2012
Showing with 24 additions and 1 deletion.
  1. +3 −1 lib/downcase_route_middleware.rb
  2. +21 −0 spec/lib/downcase_route_middleware_spec.rb
@@ -5,7 +5,9 @@ def initialize(app)
end
def call(env)
- env['PATH_INFO'] = env['PATH_INFO'].downcase
+ unless env['PATH_INFO'].match(/^\/assets\/.+/)
+ env['PATH_INFO'] = env['PATH_INFO'].downcase
+ end
@app.call(env)
end
@@ -0,0 +1,21 @@
+describe DowncaseRouteMiddleware do
+ let(:app) { stub }
+ let(:middleware) { DowncaseRouteMiddleware.new(app) }
+ subject(:env) {{ 'PATH_INFO' => path }}
+
+ before do
+ app.stub(:call).with(env)
+ middleware.call(env)
+ end
+
+ context 'request to /Petitions/1' do
+ let(:path) { '/Petitions/1' }
+ it { should include('PATH_INFO' => '/petitions/1') }
+ end
+
+ context 'request to /assets/Font.ttf' do
+ let(:path) { '/assets/Font.ttf' }
+ it { should include('PATH_INFO' => '/assets/Font.ttf') }
+ end
+
+end

0 comments on commit 72cc48d

Please sign in to comment.