-
Notifications
You must be signed in to change notification settings - Fork 757
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rewrite-rules): enable live updating of rewrite rules for both s…
…tatic server & proxy
- Loading branch information
Showing
15 changed files
with
348 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.