diff --git a/transforms/__testfixtures__/v4-deprecated-signatures/redirect.input.ts b/transforms/__testfixtures__/v4-deprecated-signatures/redirect.input.ts index b31fa65..0fd8c58 100644 --- a/transforms/__testfixtures__/v4-deprecated-signatures/redirect.input.ts +++ b/transforms/__testfixtures__/v4-deprecated-signatures/redirect.input.ts @@ -11,6 +11,14 @@ app.get("/", function (req, response) { response.redirect("/other-page", 301); }); +app.get("/", function (req, res) { + res.redirect(301, "/other-page"); +}); + +app.get("/", function (req, res) { + res.redirect("/other-page"); +}); + app.get("/", function (req, res) { redirect(301, "/other-page"); }); \ No newline at end of file diff --git a/transforms/__testfixtures__/v4-deprecated-signatures/redirect.output.ts b/transforms/__testfixtures__/v4-deprecated-signatures/redirect.output.ts index f14a6b6..2872fef 100644 --- a/transforms/__testfixtures__/v4-deprecated-signatures/redirect.output.ts +++ b/transforms/__testfixtures__/v4-deprecated-signatures/redirect.output.ts @@ -11,6 +11,14 @@ app.get("/", function (req, response) { response.redirect(301, "/other-page"); }); +app.get("/", function (req, res) { + res.redirect(301, "/other-page"); +}); + +app.get("/", function (req, res) { + res.redirect("/other-page"); +}); + app.get("/", function (req, res) { redirect(301, "/other-page"); }); \ No newline at end of file diff --git a/transforms/v4-deprecated-signatures.ts b/transforms/v4-deprecated-signatures.ts index d54fda2..232d029 100644 --- a/transforms/v4-deprecated-signatures.ts +++ b/transforms/v4-deprecated-signatures.ts @@ -124,8 +124,11 @@ export default function transformer(file: FileInfo, _api: API): string { }, }) .map((path) => { - if (path.value.arguments.length === 2) { - path.value.arguments.reverse() + const args = path.value.arguments + + // if its already in the correct order, dont reverse + if (args.length === 2 && args[0]?.type !== 'NumericLiteral') { + args.reverse() } return path