Commit 1879e7006e7872af61332facf5f6d0adfe000695
1 parent
0c9aee4f40
Exists in
master
APISERVER: /products/del optimized
Showing 1 changed file with 8 additions and 4 deletions Side-by-side Diff
api-server/router-products.js
... | ... | @@ -47,21 +47,25 @@ function pageAdd(req, res, next) { |
47 | 47 | } |
48 | 48 | |
49 | 49 | function pageDel(req, res, next) { |
50 | - if (!req.params.product || !req.params.product.trim()) { | |
50 | + let products = req.params.product || req.query.product | |
51 | + if (!products) { | |
51 | 52 | res.json({ |
52 | 53 | method: '/products/del', |
53 | 54 | error: true, |
54 | - error_msg: 'Usage: /products/del/<PRODUCT_TO_DELETE>' | |
55 | + error_msg: 'Usage: /products/del/<PRODUCT_TO_DELETE> or /products/del?product=<PRODUCT_TO_DELETE>' | |
55 | 56 | }); |
56 | 57 | |
57 | 58 | return; |
58 | 59 | } |
59 | 60 | |
61 | + if (typeof products === 'string') { | |
62 | + products = products.trim().split(/[\s,]*/); | |
63 | + } | |
64 | + | |
60 | 65 | config.products.map(function(x) { return x.toUpperCase(); }); |
61 | - const products = req.params.product.split(','); | |
62 | 66 | const productsCount = products.length; |
63 | 67 | for (let i=0; i<productsCount; i++) { |
64 | - const product = products[i].trim().toUpperCase(); | |
68 | + const product = products[i].toUpperCase(); | |
65 | 69 | const idx = config.products.indexOf(product); |
66 | 70 | if (idx >= 0) { |
67 | 71 | matrix.config_is_dirty = true; |