Commit d03c2716 authored by Terence Lee's avatar Terence Lee Committed by GitHub

Merge pull request #62 from heroku/clean_urls_conflict

Fix #57. Clean URLs clean even if there's a directory
parents fb0a4954 df1001f2
......@@ -46,7 +46,7 @@ http {
mruby_post_read_handler /app/bin/config/lib/ngx_mruby/headers.rb cache;
mruby_set $fallback /app/bin/config/lib/ngx_mruby/routes_fallback.rb cache;
<% if clean_urls %>
try_files $uri $uri/ $uri.html $fallback;
try_files $uri.html $uri $uri/ $fallback;
<% else %>
try_files $uri $uri/ $fallback;
<% end %>
......@@ -70,7 +70,7 @@ http {
mruby_set $path /app/bin/config/lib/ngx_mruby/routes_path.rb cache;
mruby_set $fallback /app/bin/config/lib/ngx_mruby/routes_fallback.rb cache;
<% if clean_urls %>
try_files $uri $uri/ /$uri.html $path $fallback;
try_files $uri.html $uri $uri/ $path $fallback;
<% else %>
try_files $uri $path $fallback;
<% end %>
......
......@@ -68,6 +68,23 @@ RSpec.describe "Simple" do
expect(response.body.chomp).to eq("bar")
end
end
context "when there is a conflict" do
let(:name) { "clean_urls_conflict" }
it "should be able to handle when a directory and .html file share the same name" do
app.run do
response = app.get("/foo/bar")
expect(response.code).to eq("200")
expect(response.body.chomp).to eq("bar")
response = app.get("/foo")
expect(response.code).to eq("200")
expect(response.body.chomp).to eq("foobar")
end
end
end
end
describe "routes" do
......@@ -548,9 +565,13 @@ STATIC_JSON
expect(response.code).to eq("302")
expect(app.get(response["location"]).body.chomp).to eq("goodbye")
response = app.get("/foo")
response = app.get("/hello")
expect(response.code).to eq("200")
expect(response.body.chomp).to eq("hello world")
response = app.get("/foo")
expect(response.code).to eq("200")
expect(response.body.chomp).to eq("foo")
end
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment