Skip to content

Commit

Permalink
fix(server-routes): strip trailing slash from route definitions - fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
shakyShane committed May 10, 2016
1 parent 1689cea commit 7f9ed9c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/server/static-server.js
Expand Up @@ -58,6 +58,10 @@ module.exports = function createServer (bs, scripts) {
}

return mw.concat(server.get("routes").map(function (root, urlPath) {
// strip trailing slash
if (urlPath[urlPath.length - 1] === "/") {
urlPath = urlPath.slice(0, -1);
}
return {
route: urlPath,
id: "Browsersync Server Routes Middleware - " + _routes++,
Expand Down
10 changes: 9 additions & 1 deletion test/specs/e2e/server/e2e.server.routes.js
Expand Up @@ -18,7 +18,8 @@ describe("E2E server test with routes", function () {
baseDir: "test/fixtures",
routes: {
"/shane": "test/fixtures",
"/kittie": "test/fixtures"
"/kittie": "test/fixtures",
"/node_modules/": "node_modules"
}
},
logLevel: "silent",
Expand Down Expand Up @@ -70,4 +71,11 @@ describe("E2E server test with routes", function () {
done();
});
});

it("serves from the node_modules directory", function (done) {

request(instance.server)
.get("/node_modules/chai/index.js")
.expect(200, done);
});
});

0 comments on commit 7f9ed9c

Please sign in to comment.