Skip to content

Commit 7f9ed9c

Browse files
committed
fix(server-routes): strip trailing slash from route definitions - fixes #1063
1 parent 1689cea commit 7f9ed9c

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

lib/server/static-server.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ module.exports = function createServer (bs, scripts) {
5858
}
5959

6060
return mw.concat(server.get("routes").map(function (root, urlPath) {
61+
// strip trailing slash
62+
if (urlPath[urlPath.length - 1] === "/") {
63+
urlPath = urlPath.slice(0, -1);
64+
}
6165
return {
6266
route: urlPath,
6367
id: "Browsersync Server Routes Middleware - " + _routes++,

test/specs/e2e/server/e2e.server.routes.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ describe("E2E server test with routes", function () {
1818
baseDir: "test/fixtures",
1919
routes: {
2020
"/shane": "test/fixtures",
21-
"/kittie": "test/fixtures"
21+
"/kittie": "test/fixtures",
22+
"/node_modules/": "node_modules"
2223
}
2324
},
2425
logLevel: "silent",
@@ -70,4 +71,11 @@ describe("E2E server test with routes", function () {
7071
done();
7172
});
7273
});
74+
75+
it("serves from the node_modules directory", function (done) {
76+
77+
request(instance.server)
78+
.get("/node_modules/chai/index.js")
79+
.expect(200, done);
80+
});
7381
});

0 commit comments

Comments
 (0)