Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for #625 broken historyApiFallback #627

Merged
merged 2 commits into from
Sep 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,11 @@ function Server(compiler, options) {
var defaultFeatures = ["setup", "headers", "middleware"];
if(options.proxy)
defaultFeatures.push("proxy", "middleware");
if(options.historyApiFallback)
defaultFeatures.push("historyApiFallback", "middleware");
defaultFeatures.push("magicHtml");
if(options.contentBase !== false)
defaultFeatures.push("contentBase");
if(options.historyApiFallback)
defaultFeatures.push("historyApiFallback", "middleware");
// compress is placed last and uses unshift so that it will be the first middleware used
if(options.compress)
defaultFeatures.unshift("compress");
Expand Down
42 changes: 40 additions & 2 deletions test/HistoryApiFallback.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ describe("HistoryApiFallback", function() {
server = helper.start(config2, {
contentBase: path.join(__dirname, "fixtures/historyapifallback-2-config"),
historyApiFallback: {
index: "/bar.html",
disableDotRule: true
index: "/bar.html"
}
}, done);
req = request(server.app);
Expand All @@ -72,4 +71,43 @@ describe("HistoryApiFallback", function() {
.expect(200, /Other file/, done);
});
});

describe("as object with contentBase and rewrites", function() {
before(function(done) {
server = helper.start(config2, {
contentBase: path.join(__dirname, "fixtures/historyapifallback-2-config"),
historyApiFallback: {
rewrites: [
{
from: /other/,
to: "/other.html"
},
{
from: /.*/,
to: "/bar.html"
}
]
}
}, done);
req = request(server.app);
});

it("historyApiFallback respect rewrites for index", function(done) {
req.get("/")
.accept("html")
.expect(200, /Foobar/, done);
});

it("historyApiFallback respect rewrites and shows index for unknown urls", function(done) {
req.get("/acme")
.accept("html")
.expect(200, /Foobar/, done);
});

it("historyApiFallback respect any other specified rewrites", function(done) {
req.get("/other")
.accept("html")
.expect(200, /Other file/, done);
});
});
});