From 9c3180c79d7ec4fb88372deb4ef7036400e182e3 Mon Sep 17 00:00:00 2001 From: Shane Osbourne Date: Fri, 22 May 2015 08:30:31 +0100 Subject: [PATCH 1/7] move snippet middleware to init task --- lib/async-tasks.js | 4 ++++ lib/async.js | 12 ++++++++++++ lib/server/proxy-server.js | 15 +++++---------- lib/server/static-server.js | 10 ++-------- lib/snippet.js | 10 ++++++++-- package.json | 2 +- 6 files changed, 32 insertions(+), 21 deletions(-) diff --git a/lib/async-tasks.js b/lib/async-tasks.js index 198639b0c..208ebe729 100644 --- a/lib/async-tasks.js +++ b/lib/async-tasks.js @@ -29,6 +29,10 @@ module.exports = [ step: "Merging middlewares from core + plugins", fn: async.mergeMiddlewares }, + { + step: "Setting the rewrite rules middleware for snippet", + fn: async.setRewriteRules + }, { step: "Starting the Server", fn: async.startServer diff --git a/lib/async.js b/lib/async.js index 6406b194d..c70cc31bc 100644 --- a/lib/async.js +++ b/lib/async.js @@ -138,6 +138,18 @@ module.exports = { } }); }, + setRewriteRules: function (bs, done) { + var snippetUtils = require("./snippet").utils; + done(null, { + instance: { + snippetMw: snippetUtils.getSnippetMiddleware( + bs.options.get("snippet"), + bs.options.get("snippetOptions"), + bs.options.get("rewriteRules") + ) + } + }); + }, /** * @param {BrowserSync} bs * @param {Function} done diff --git a/lib/server/proxy-server.js b/lib/server/proxy-server.js index 2e76d7fc1..4cbc4e640 100644 --- a/lib/server/proxy-server.js +++ b/lib/server/proxy-server.js @@ -41,18 +41,13 @@ function getOptions (bs, scripts) { var options = bs.options; - var snippetOptions = options.get("snippetOptions").toJS(); - var proxyOptions = options.getIn(["proxy", "proxyOptions"]); - var rewrites = [snippetUtils.getRegex(options.get("snippet"), options.get("snippetOptions"))]; - - if (bs.options.get("rewriteRules")) { - rewrites = rewrites.concat(bs.options.get("rewriteRules").toJS()); - } + var proxyOptions = options.getIn(["proxy", "proxyOptions"]); + var rules = bs.snippetMw; var out = { - rules: rewrites, - whitelist: snippetOptions.whitelist, - blacklist: snippetOptions.blacklist, + rules: rules.opts.rules, + whitelist: rules.opts.whitelist, + blacklist: rules.opts.blacklist, middleware: options.get("middleware").push(getPluginMiddleware(bs, scripts)), errHandler: function (err) { bs.logger.debug("{red:[proxy error]} %s", err.message); diff --git a/lib/server/static-server.js b/lib/server/static-server.js index 3bf2de691..06e1174b3 100644 --- a/lib/server/static-server.js +++ b/lib/server/static-server.js @@ -2,7 +2,6 @@ var connect = require("connect"); var utils = require("./utils.js"); -var snippetUtils = require("./../snippet").utils; /** * @param {BrowserSync} bs @@ -39,14 +38,9 @@ module.exports = function createServer (bs, scripts) { /** * Add snippet injection middleware + * This also includes any additional middleware given from the user */ - app.use( - snippetUtils.getSnippetMiddleware( - options.get("snippet"), - options.get("snippetOptions"), - options.get("rewriteRules") - ) - ); + app.use(bs.snippetMw.middleware); /** * Add user-provided middlewares diff --git a/lib/snippet.js b/lib/snippet.js index 740c0ddc9..48fa0d30e 100644 --- a/lib/snippet.js +++ b/lib/snippet.js @@ -47,15 +47,21 @@ var utils = { }; }, getSnippetMiddleware: function (snippet, options, rewriteRules) { + return lrSnippet.create(utils.getRules(snippet, options, rewriteRules)); + }, + getRules: function (snippet, options, rewriteRules) { + var rules = [utils.getRegex(snippet, options)]; + if (rewriteRules) { rules = rules.concat(rewriteRules.toJS()); } - return lrSnippet({ + + return { rules: rules, blacklist: options.get("blacklist").toJS(), whitelist: options.get("whitelist").toJS() - }); + }; }, /** * @param {String} scripts - the client side JS diff --git a/package.json b/package.json index 464177f8b..b8f642893 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "pad-left": "^1.0.2", "portscanner": "^1.0.0", "query-string": "^2.0.0", - "resp-modifier": "^2.1.0", + "resp-modifier": "^3.1.2", "serve-index": "^1.6.3", "serve-static": "^1.9.1", "socket.io": "^1.3.5", From d14d64ee2e89317896f12d89d4897f9625162c4b Mon Sep 17 00:00:00 2001 From: Shane Osbourne Date: Fri, 22 May 2015 14:23:53 +0100 Subject: [PATCH 2/7] deps: bump foxy to 11.0.0 --- lib/server/proxy-server.js | 12 +++++++++--- package.json | 2 +- test/specs/e2e/proxy/e2e.proxy.cookies.js | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/server/proxy-server.js b/lib/server/proxy-server.js index 4cbc4e640..1e194a38e 100644 --- a/lib/server/proxy-server.js +++ b/lib/server/proxy-server.js @@ -3,6 +3,7 @@ var snippetUtils = require("./../snippet").utils; var _ = require("lodash"); var utils = require("./utils"); +var Immutable = require("immutable"); /** * @param {BrowserSync} bs @@ -43,12 +44,13 @@ function getOptions (bs, scripts) { var proxyOptions = options.getIn(["proxy", "proxyOptions"]); var rules = bs.snippetMw; + var cookies = options.getIn(["proxy", "cookies"]); var out = { rules: rules.opts.rules, whitelist: rules.opts.whitelist, blacklist: rules.opts.blacklist, - middleware: options.get("middleware").push(getPluginMiddleware(bs, scripts)), + middleware: options.get("middleware").toJS().concat(getPluginMiddleware(bs, scripts)), errHandler: function (err) { bs.logger.debug("{red:[proxy error]} %s", err.message); } @@ -62,8 +64,12 @@ function getOptions (bs, scripts) { out.reqHeaders = options.getIn(["proxy", "reqHeaders"]); } - if (options.getIn(["proxy", "cookies"])) { - out.cookies = options.getIn(["proxy", "cookies"]); + if (!_.isUndefined(cookies)) { + if (Immutable.Map.isMap(cookies)) { + out.cookies = cookies.toJS(); + } else { + out.cookies = cookies; + } } return out; diff --git a/package.json b/package.json index b8f642893..a311cef46 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "easy-extender": "^2.3.1", "eazy-logger": "^2.1.2", "emitter-steward": "^0.0.1", - "foxy": "^10.1.2", + "foxy": "^11.0.0", "immutable": "^3.6.4", "localtunnel": "^1.3.0", "lodash": "^3.8.0", diff --git a/test/specs/e2e/proxy/e2e.proxy.cookies.js b/test/specs/e2e/proxy/e2e.proxy.cookies.js index a7888f298..3cf454f43 100644 --- a/test/specs/e2e/proxy/e2e.proxy.cookies.js +++ b/test/specs/e2e/proxy/e2e.proxy.cookies.js @@ -44,7 +44,7 @@ describe("E2E proxy test with custom cookies options passed to foxy", function ( it("sets cookie stripDomain: false", function (done) { - assert.isFalse(spy.getCall(0).args[1].cookies.toJS().stripDomain); // check fn passed to foxy + assert.isFalse(spy.getCall(0).args[1].cookies.stripDomain); // check fn passed to foxy spy.restore(); From 7ef2ad58946f58d33b51568738da5e0e57640a59 Mon Sep 17 00:00:00 2001 From: Shane Osbourne Date: Fri, 22 May 2015 15:32:06 +0100 Subject: [PATCH 3/7] Add failing test for live updating --- lib/browser-sync.js | 7 ++++ .../e2e/proxy/e2e.proxy.rewrite.rules.js | 36 +++++++++++++------ 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/lib/browser-sync.js b/lib/browser-sync.js index 20819c095..10f0475e2 100644 --- a/lib/browser-sync.js +++ b/lib/browser-sync.js @@ -575,6 +575,13 @@ BrowserSync.prototype.setMany = function (fn, opts) { return this.options; }; +/** + * + */ +BrowserSync.prototype.addRewriteRule = function () { + +}; + /** * Handle Browser Reloads */ diff --git a/test/specs/e2e/proxy/e2e.proxy.rewrite.rules.js b/test/specs/e2e/proxy/e2e.proxy.rewrite.rules.js index 2e4ef10f5..72f840d42 100644 --- a/test/specs/e2e/proxy/e2e.proxy.rewrite.rules.js +++ b/test/specs/e2e/proxy/e2e.proxy.rewrite.rules.js @@ -9,14 +9,16 @@ var assert = require("chai").assert; describe("E2E proxy test with rewrite rules", function () { - var instance, server, options; + var bs, server, options; before(function (done) { browserSync.reset(); var app = connect(); - app.use(serveStatic("./test/fixtures")); + app.use("/index.html", function (req, res, next) { + res.end('some content'); + }); server = app.listen(); var proxytarget = "http://localhost:" + server.address().port; @@ -26,34 +28,48 @@ describe("E2E proxy test with rewrite rules", function () { open: false, rewriteRules: [ { - match: /Forms/g, + match: /content/g, fn: function () { - return "Shane's forms"; + return "awesome content"; } } ] }; - instance = browserSync.init([], config, function (err, bs) { + bs = browserSync.init([], config, function (err, bs) { options = bs.options; done(); }).instance; }); after(function () { - instance.cleanup(); + bs.cleanup(); server.close(); }); - it("serves files with HTML rewritten", function (done) { + it.only("serves files with HTML rewritten", function (done) { - request(instance.server) + request(bs.server) .get("/index.html") .set("accept", "text/html") .expect(200) .end(function (err, res) { - assert.include(res.text, "Shane's forms"); - done(); + + assert.include(res.text, "some awesome content"); + + bs.addRewriteRule({ + match: "some awesome content", + replace: "some REALLY awesome content" + }); + + request(bs.server) + .get("/index.html") + .set("accept", "text/html") + .expect(200) + .end(function (err, res) { + console.log(res.text); + done(); + }); }); }); }); From bf0c4f746e6b1e480ebfac31c1ab4735fbc4e9c7 Mon Sep 17 00:00:00 2001 From: Shane Osbourne Date: Fri, 22 May 2015 16:58:34 +0100 Subject: [PATCH 4/7] tests: update specs to reflect bump to foxy --- lib/browser-sync.js | 40 +++++++++- lib/server/proxy-server.js | 6 +- test/specs/e2e/proxy/e2e.proxy.cookies.js | 2 +- .../e2e/proxy/e2e.proxy.proxy.options.js | 2 +- test/specs/e2e/proxy/e2e.proxy.req.headers.js | 2 +- .../e2e/proxy/e2e.proxy.rewrite.rules.add.js | 74 +++++++++++++++++++ .../e2e/proxy/e2e.proxy.rewrite.rules.js | 29 ++------ .../proxy/e2e.proxy.rewrite.rules.remove.js | 70 ++++++++++++++++++ 8 files changed, 195 insertions(+), 30 deletions(-) create mode 100644 test/specs/e2e/proxy/e2e.proxy.rewrite.rules.add.js create mode 100644 test/specs/e2e/proxy/e2e.proxy.rewrite.rules.remove.js diff --git a/lib/browser-sync.js b/lib/browser-sync.js index 10f0475e2..551523c61 100644 --- a/lib/browser-sync.js +++ b/lib/browser-sync.js @@ -576,10 +576,46 @@ BrowserSync.prototype.setMany = function (fn, opts) { }; /** - * + * Remove a rewrite rule by id */ -BrowserSync.prototype.addRewriteRule = function () { +BrowserSync.prototype.removeRewriteRule = function (id) { + var bs = this; + var mode = bs.options.get("mode"); + + if (mode === "snippet") { + return; + } + if (mode === "server") { + bs.snippetMw.opts.rules = bs.snippetMw.opts.rules.filter(fn); + } + + if (bs.options.get("mode") === "proxy") { + bs.proxy.config.rules = bs.proxy.config.rules.filter(fn); + } + + function fn (item) { + if (item.id) { + return item.id !== id; + } + return true; + } +}; + +/** + * Add a new rewrite rule to the stack + * @param {Object} rule + */ +BrowserSync.prototype.addRewriteRule = function (rule) { + var bs = this; + + if (bs.options.get("mode") === "server") { + bs.snippetMw.opts.rules.push(rule); + } + + if (bs.options.get("mode") === "proxy") { + bs.proxy.config.rules.push(rule); + } }; /** diff --git a/lib/server/proxy-server.js b/lib/server/proxy-server.js index 1e194a38e..0f1a9c783 100644 --- a/lib/server/proxy-server.js +++ b/lib/server/proxy-server.js @@ -22,9 +22,11 @@ module.exports = function createProxyServer (bs, scripts) { var opts = getOptions(bs, scripts); - var app = require("foxy")(options.getIn(["proxy", "target"]), opts); + var foxy = require("foxy").create(options.getIn(["proxy", "target"]), opts); - var proxy = utils.getServer(app, bs.options); + bs.proxy = foxy; + + var proxy = utils.getServer(foxy.app, bs.options); /** * How best to handle websockets going forward? diff --git a/test/specs/e2e/proxy/e2e.proxy.cookies.js b/test/specs/e2e/proxy/e2e.proxy.cookies.js index 3cf454f43..20a62d57c 100644 --- a/test/specs/e2e/proxy/e2e.proxy.cookies.js +++ b/test/specs/e2e/proxy/e2e.proxy.cookies.js @@ -33,7 +33,7 @@ describe("E2E proxy test with custom cookies options passed to foxy", function ( logLevel: "silent" }; - spy = require("sinon").spy(require.cache[foxyPath], "exports"); + spy = require("sinon").spy(require.cache[foxyPath].exports, "create"); bs = browserSync.init(config, done).instance; }); diff --git a/test/specs/e2e/proxy/e2e.proxy.proxy.options.js b/test/specs/e2e/proxy/e2e.proxy.proxy.options.js index 79c32de7e..080eabc8d 100644 --- a/test/specs/e2e/proxy/e2e.proxy.proxy.options.js +++ b/test/specs/e2e/proxy/e2e.proxy.proxy.options.js @@ -33,7 +33,7 @@ describe("E2E proxy test with `proxyOptions`", function () { logLevel: "silent" }; - spy = require("sinon").spy(require.cache[foxyPath], "exports"); + spy = require("sinon").spy(require.cache[foxyPath].exports, "create"); bs = browserSync.init(config, done).instance; }); diff --git a/test/specs/e2e/proxy/e2e.proxy.req.headers.js b/test/specs/e2e/proxy/e2e.proxy.req.headers.js index 11cfd0153..607617b22 100644 --- a/test/specs/e2e/proxy/e2e.proxy.req.headers.js +++ b/test/specs/e2e/proxy/e2e.proxy.req.headers.js @@ -35,7 +35,7 @@ describe("E2E proxy test with custom req headers", function () { logLevel: "silent" }; - spy = require("sinon").spy(require.cache[foxyPath], "exports"); + spy = require("sinon").spy(require.cache[foxyPath].exports, "create"); bs = browserSync.init(config, done).instance; }); diff --git a/test/specs/e2e/proxy/e2e.proxy.rewrite.rules.add.js b/test/specs/e2e/proxy/e2e.proxy.rewrite.rules.add.js new file mode 100644 index 000000000..3c9f437a5 --- /dev/null +++ b/test/specs/e2e/proxy/e2e.proxy.rewrite.rules.add.js @@ -0,0 +1,74 @@ +"use strict"; + +var browserSync = require("../../../../index"); + +var connect = require("connect"); +var serveStatic = require("serve-static"); +var request = require("supertest"); +var assert = require("chai").assert; + +describe("E2E proxy test with adding rewrite rules dynamically", function () { + + var bs, server, options; + + before(function (done) { + + browserSync.reset(); + + var app = connect(); + app.use(serveStatic("test/fixtures")); + server = app.listen(); + var proxytarget = "http://localhost:" + server.address().port; + + var config = { + proxy: proxytarget, + logLevel: "silent", + open: false, + rewriteRules: [ + { + match: /BrowserSync/g, + fn: function () { + return "BROWSERSYNC"; + } + } + ] + }; + + bs = browserSync.init([], config, function (err, bs) { + options = bs.options; + done(); + }).instance; + }); + + after(function () { + bs.cleanup(); + server.close(); + }); + + it("can add rules on the fly", function (done) { + + request(bs.server) + .get("/index.html") + .set("accept", "text/html") + .expect(200) + .end(function (err, res) { + + assert.include(res.text, "BROWSERSYNC"); + + bs.addRewriteRule({ + match: "BROWSERSYNC", + replace: "browsersync" + }, {id: "myrule"}); + + request(bs.server) + .get("/index.html") + .set("accept", "text/html") + .expect(200) + .end(function (err, res) { + assert.include(res.text, "browsersync"); + assert.notInclude(res.text, "BROWSERSYNC"); + done(); + }); + }); + }); +}); diff --git a/test/specs/e2e/proxy/e2e.proxy.rewrite.rules.js b/test/specs/e2e/proxy/e2e.proxy.rewrite.rules.js index 72f840d42..e6c2f24f2 100644 --- a/test/specs/e2e/proxy/e2e.proxy.rewrite.rules.js +++ b/test/specs/e2e/proxy/e2e.proxy.rewrite.rules.js @@ -16,9 +16,7 @@ describe("E2E proxy test with rewrite rules", function () { browserSync.reset(); var app = connect(); - app.use("/index.html", function (req, res, next) { - res.end('some content'); - }); + app.use(serveStatic("test/fixtures")); server = app.listen(); var proxytarget = "http://localhost:" + server.address().port; @@ -28,9 +26,9 @@ describe("E2E proxy test with rewrite rules", function () { open: false, rewriteRules: [ { - match: /content/g, + match: /BrowserSync/g, fn: function () { - return "awesome content"; + return "BROWSERSYNC"; } } ] @@ -47,29 +45,14 @@ describe("E2E proxy test with rewrite rules", function () { server.close(); }); - it.only("serves files with HTML rewritten", function (done) { - + it("can add rules on the fly", function (done) { request(bs.server) .get("/index.html") .set("accept", "text/html") .expect(200) .end(function (err, res) { - - assert.include(res.text, "some awesome content"); - - bs.addRewriteRule({ - match: "some awesome content", - replace: "some REALLY awesome content" - }); - - request(bs.server) - .get("/index.html") - .set("accept", "text/html") - .expect(200) - .end(function (err, res) { - console.log(res.text); - done(); - }); + assert.include(res.text, "BROWSERSYNC"); + done(); }); }); }); diff --git a/test/specs/e2e/proxy/e2e.proxy.rewrite.rules.remove.js b/test/specs/e2e/proxy/e2e.proxy.rewrite.rules.remove.js new file mode 100644 index 000000000..16ab206c7 --- /dev/null +++ b/test/specs/e2e/proxy/e2e.proxy.rewrite.rules.remove.js @@ -0,0 +1,70 @@ +"use strict"; + +var browserSync = require("../../../../index"); + +var connect = require("connect"); +var serveStatic = require("serve-static"); +var request = require("supertest"); +var assert = require("chai").assert; + +describe("E2E proxy test with adding and removing rewrite rules dynamically", function () { + + var bs, server, options; + + before(function (done) { + + browserSync.reset(); + + var app = connect(); + app.use(serveStatic("test/fixtures")); + server = app.listen(); + var proxytarget = "http://localhost:" + server.address().port; + + var config = { + proxy: proxytarget, + logLevel: "silent", + open: false, + online: false + }; + + bs = browserSync.init([], config, function (err, bs) { + options = bs.options; + done(); + }).instance; + }); + + after(function () { + bs.cleanup(); + server.close(); + }); + + it("can add rules on the fly", function (done) { + + bs.addRewriteRule({ + match: "BrowserSync", + replace: "BROWSERSYNC", + id: "myrule" + }); + + request(bs.server) + .get("/index.html") + .set("accept", "text/html") + .expect(200) + .end(function (err, res) { + + assert.include(res.text, "BROWSERSYNC"); + + bs.removeRewriteRule("myrule"); + + request(bs.server) + .get("/index.html") + .set("accept", "text/html") + .expect(200) + .end(function (err, res) { + assert.include(res.text, "BrowserSync"); + assert.notInclude(res.text, "BROWSERSYNC"); + done(); + }); + }); + }); +}); From d3fff5c39ca4ef976952c4907d45730ef368a253 Mon Sep 17 00:00:00 2001 From: Shane Osbourne Date: Fri, 22 May 2015 20:49:34 +0100 Subject: [PATCH 5/7] tests: more e2e tests for live updating rewrite rules --- lib/server/proxy-server.js | 6 +- .../server/e2e.server.rewrite.rules.add.js | 49 +++++++++++++++ .../server/e2e.server.rewrite.rules.remove.js | 61 +++++++++++++++++++ 3 files changed, 112 insertions(+), 4 deletions(-) create mode 100644 test/specs/e2e/server/e2e.server.rewrite.rules.add.js create mode 100644 test/specs/e2e/server/e2e.server.rewrite.rules.remove.js diff --git a/lib/server/proxy-server.js b/lib/server/proxy-server.js index 0f1a9c783..7985a7a3a 100644 --- a/lib/server/proxy-server.js +++ b/lib/server/proxy-server.js @@ -22,11 +22,9 @@ module.exports = function createProxyServer (bs, scripts) { var opts = getOptions(bs, scripts); - var foxy = require("foxy").create(options.getIn(["proxy", "target"]), opts); + bs.proxy = require("foxy").create(options.getIn(["proxy", "target"]), opts); - bs.proxy = foxy; - - var proxy = utils.getServer(foxy.app, bs.options); + var proxy = utils.getServer(bs.proxy.app, bs.options); /** * How best to handle websockets going forward? diff --git a/test/specs/e2e/server/e2e.server.rewrite.rules.add.js b/test/specs/e2e/server/e2e.server.rewrite.rules.add.js new file mode 100644 index 000000000..d6f0659cf --- /dev/null +++ b/test/specs/e2e/server/e2e.server.rewrite.rules.add.js @@ -0,0 +1,49 @@ +"use strict"; + +var browserSync = require("../../../../index"); + +var request = require("supertest"); +var assert = require("chai").assert; + +describe("E2E server test with rewrite rules added on the fly", function () { + + var bs; + + before(function (done) { + + browserSync.reset(); + + var config = { + server: { + baseDir: "test/fixtures" + }, + logLevel: "silent", + open: false + }; + + bs = browserSync.init(config, done).instance; + }); + + after(function () { + bs.cleanup(); + }); + + it("serves files with HTML rewritten", function (done) { + + bs.addRewriteRule({ + match: /Forms/g, + fn: function () { + return "Shane's forms"; + } + }); + + request(bs.server) + .get("/index.html") + .set("accept", "text/html") + .expect(200) + .end(function (err, res) { + assert.include(res.text, "Shane's forms"); + done(); + }); + }); +}); diff --git a/test/specs/e2e/server/e2e.server.rewrite.rules.remove.js b/test/specs/e2e/server/e2e.server.rewrite.rules.remove.js new file mode 100644 index 000000000..0d15b7cd9 --- /dev/null +++ b/test/specs/e2e/server/e2e.server.rewrite.rules.remove.js @@ -0,0 +1,61 @@ +"use strict"; + +var browserSync = require("../../../../index"); + +var request = require("supertest"); +var assert = require("chai").assert; + +describe("E2E server test with rewrite rules removed on the fly", function () { + + var bs; + + before(function (done) { + + browserSync.reset(); + + var config = { + server: { + baseDir: "test/fixtures" + }, + logLevel: "silent", + open: false + }; + + bs = browserSync.init(config, done).instance; + }); + + after(function () { + bs.cleanup(); + }); + + it("serves files with HTML rewritten", function (done) { + + bs.addRewriteRule({ + id: "myrule", + match: /Forms/g, + fn: function () { + return "Shane's forms"; + } + }); + + request(bs.server) + .get("/index.html") + .set("accept", "text/html") + .expect(200) + .end(function (err, res) { + assert.include(res.text, "Shane's forms"); + + bs.removeRewriteRule("myrule"); + + request(bs.server) + .get("/index.html") + .set("accept", "text/html") + .expect(200) + .end(function (err, res) { + assert.notInclude(res.text, "Shane's forms"); + done(); + }); + + }); + }); +}); From 1262a4cb566568b4dc59010cc452d4ba81cb9666 Mon Sep 17 00:00:00 2001 From: Shane Osbourne Date: Fri, 22 May 2015 21:16:02 +0100 Subject: [PATCH 6/7] remove unnecessary snippet-mode check --- lib/browser-sync.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/browser-sync.js b/lib/browser-sync.js index 551523c61..941fcc248 100644 --- a/lib/browser-sync.js +++ b/lib/browser-sync.js @@ -582,15 +582,11 @@ BrowserSync.prototype.removeRewriteRule = function (id) { var bs = this; var mode = bs.options.get("mode"); - if (mode === "snippet") { - return; - } - if (mode === "server") { bs.snippetMw.opts.rules = bs.snippetMw.opts.rules.filter(fn); } - if (bs.options.get("mode") === "proxy") { + if (mode === "proxy") { bs.proxy.config.rules = bs.proxy.config.rules.filter(fn); } From e7d551c48e76b158b85055e7f9aa466b810a7044 Mon Sep 17 00:00:00 2001 From: Shane Osbourne Date: Fri, 22 May 2015 21:18:45 +0100 Subject: [PATCH 7/7] only set cookie options for proxy if it's a Map --- lib/server/proxy-server.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/server/proxy-server.js b/lib/server/proxy-server.js index 7985a7a3a..eacefef3c 100644 --- a/lib/server/proxy-server.js +++ b/lib/server/proxy-server.js @@ -67,8 +67,6 @@ function getOptions (bs, scripts) { if (!_.isUndefined(cookies)) { if (Immutable.Map.isMap(cookies)) { out.cookies = cookies.toJS(); - } else { - out.cookies = cookies; } }