From 3bc3c6d3a724a26064ba76e6cddc4011e36bc274 Mon Sep 17 00:00:00 2001 From: Glavin Wiechert Date: Sat, 16 Apr 2016 16:15:47 -0300 Subject: [PATCH] See #924. Add JavaScript test that is reported to crash Atom --- .../javascript/expected/test2.js | 65 ++++++++++++++++++ .../javascript/original/test2.js | 66 +++++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 examples/nested-jsbeautifyrc/javascript/expected/test2.js create mode 100644 examples/nested-jsbeautifyrc/javascript/original/test2.js diff --git a/examples/nested-jsbeautifyrc/javascript/expected/test2.js b/examples/nested-jsbeautifyrc/javascript/expected/test2.js new file mode 100644 index 0000000..1063943 --- /dev/null +++ b/examples/nested-jsbeautifyrc/javascript/expected/test2.js @@ -0,0 +1,65 @@ +/** + * Created by Pierre on 05.04.16. + */ +var express = require("express"); +var router = express.Router({ + mergeParams: true +}); +var Customer = require("../../models/customers"); +var middleware = require("../../middleware/index.js"); +//TODO add a way for pagination +//INDEX - show all Customers +router.get("/", function (req, res) { + var regexid = /^[a-f\d]{24}$/i; + var search = req.query.search; + + if (regexid.exec(search) !== null) { + Customer.findById(search, function (err, foundCustomer) { + if (err) { + console.log(err); + } else { + res.end(JSON.stringify([foundCustomer])); + } + }); + } else { + var re = new RegExp(search); + var offset = 0; + if (req.query.offset) { + offset = req.query.offset; + } + Customer.find().or([{ + 'name': { + $regex: re + } + }, { + 'mail': { + $regex: re + } + }, { + 'phone': { + $regex: re + } + }, { + 'customernumber': { + $regex: re + } + }, { + 'street': { + $regex: re + } + }]).skip(parseInt(offset)).limit(20).exec(function (err, allCustomers) { + if (err) { + console.log(err); + } else if (allCustomers.length === 0) { + res.sendStatus(404); + } else { + res.end(JSON.stringify(allCustomers)); + } + }); + } + +}); + +// TODO add findsingle for id + +module.exports = router; \ No newline at end of file diff --git a/examples/nested-jsbeautifyrc/javascript/original/test2.js b/examples/nested-jsbeautifyrc/javascript/original/test2.js new file mode 100644 index 0000000..1549b5b --- /dev/null +++ b/examples/nested-jsbeautifyrc/javascript/original/test2.js @@ -0,0 +1,66 @@ +/** + * Created by Pierre on 05.04.16. + */ +var express = require("express"); +var router = express.Router({ + mergeParams: true +}); +var Customer = require("../../models/customers"); +var middleware = require("../../middleware/index.js"); +//TODO add a way for pagination +//INDEX - show all Customers +router.get("/", function(req, res) { + var regexid = /^[a-f\d]{24}$/i; + var search = req.query.search; + + if (regexid.exec(search) !== null) { + Customer.findById(search, function(err, foundCustomer) { + if (err) { + console.log(err); + } else { + res.end(JSON.stringify([foundCustomer])); + } + }); + } else { + var re = new RegExp(search); + var offset = 0; + if (req.query.offset) { + offset = req.query.offset; + } + Customer.find().or([{ + 'name': { + $regex: re + } + }, { + 'mail': { + $regex: re + } + }, { + 'phone': { + $regex: re + } + }, { + 'customernumber': { + $regex: re + } + }, { + 'street': { + $regex: re + } + }]).skip(parseInt(offset)).limit(20).exec(function(err, allCustomers) { + if (err) { + console.log(err); + } else if (allCustomers.length === 0) { + res.sendStatus(404); + } else { + res.end(JSON.stringify(allCustomers)); + } + }); + } + + +}); + +// TODO add findsingle for id + +module.exports = router; \ No newline at end of file