Skip to content

Commit

Permalink
Revert "feat: add legacyRoutes option (#223)"
Browse files Browse the repository at this point in the history
This reverts commit da6f09c.

After the version 8 breaking changes in path-to-regexp this is
essentially a no-op, so this is not a breaking change.

closes #224
  • Loading branch information
fatso83 committed Sep 13, 2024
1 parent 840bef6 commit fe6d236
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 34 deletions.
10 changes: 0 additions & 10 deletions lib/fake-server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ var fakeServer = {
fakeHTTPMethods: true,
logger: true,
unsafeHeadersEnabled: true,
legacyRoutes: true,
};

// eslint-disable-next-line no-param-reassign
Expand Down Expand Up @@ -214,8 +213,6 @@ var fakeServer = {

log: log,

legacyRoutes: true,

respondWith: function respondWith(method, url, body) {
if (arguments.length === 1 && typeof method !== "function") {
this.response = responseArray(method);
Expand Down Expand Up @@ -255,13 +252,6 @@ var fakeServer = {
// eslint-disable-next-line no-param-reassign
url = url.replace(/\/\*/g, "/*path");
}

if (this.legacyRoutes) {
if (url.includes("?")) {
// eslint-disable-next-line no-param-reassign
url = url.replace("?", "\\?");
}
}
}
push.call(this.responses, {
method: method,
Expand Down
25 changes: 1 addition & 24 deletions lib/fake-server/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,6 @@ describe("sinonFakeServer", function () {
"fakeServer.create should not accept 'foo' settings",
);
});

it("allows the 'legacyRoutes' setting", function () {
var server = sinonFakeServer.create({
legacyRoutes: false,
});
assert(
server.legacyRoutes === false,
"fakeServer.create should accept 'legacyRoutes' setting",
);
});
});

it("fakes XMLHttpRequest", function () {
Expand Down Expand Up @@ -913,9 +903,8 @@ describe("sinonFakeServer", function () {
assert(handler.calledOnce);
});

it("yields response to handler when url contains escaped RegExp characters in non-legacy mode", function () {
it("yields response to request function handler when url contains RegExp characters", function () {
var handler = sinon.spy();
this.server.legacyRoutes = false;
this.server.respondWith("GET", "/hello\\?world", handler);
var xhr = new FakeXMLHttpRequest();
xhr.open("GET", "/hello?world");
Expand All @@ -926,18 +915,6 @@ describe("sinonFakeServer", function () {
assert(handler.calledOnce);
});

it("yields response to handler when url contains unescaped RegExp characters in legacy mode", function () {
var handler = sinon.spy();
this.server.respondWith("GET", "/hello?world", handler);
var xhr = new FakeXMLHttpRequest();
xhr.open("GET", "/hello?world");
xhr.send();

this.server.respond();

assert(handler.calledOnce);
});

function equalMatcher(expected) {
return function (test) {
return expected === test;
Expand Down

0 comments on commit fe6d236

Please sign in to comment.