From 26f3f1bcd098b926497e840ff8c4ff1b7adcaa4a Mon Sep 17 00:00:00 2001 From: muxator Date: Wed, 13 Feb 2019 14:01:24 +0100 Subject: [PATCH] db/Pad.js: make "force" parameter non optional in Pad.prototype.copy() This function was simulating two overloads: 1. copy(destinationID, force, callback) 2. copy(destinationID, callback), in this case "force" would be assumed false But all the call sites always used the version with arity 3. Thus, we can remove that optionality and always assume that the funcion will be called with three parameters. This will simplify future work. --- src/node/db/Pad.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/node/db/Pad.js b/src/node/db/Pad.js index 91ab7f792..4e7d16987 100644 --- a/src/node/db/Pad.js +++ b/src/node/db/Pad.js @@ -454,15 +454,12 @@ Pad.prototype.copy = function copy(destinationID, force, callback) { var _this = this; var destGroupID; - // make force optional - if (typeof force == "function") { - callback = force; - force = false; + // allow force to be a string + if (typeof force === "string") { + force = (force.toLowerCase() === "true"); + } else { + force = !!force; } - else if (force == undefined || force.toLowerCase() != "true") { - force = false; - } - else force = true; // Kick everyone from this pad. // This was commented due to https://github.com/ether/etherpad-lite/issues/3183.