Compare View
Commits (5)
Changes
Showing 3 changed files 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; |
... | ... | @@ -80,6 +84,10 @@ function pageDel(req, res, next) { |
80 | 84 | |
81 | 85 | router.get('/', pageIndex); |
82 | 86 | router.get('/add/:product', pageAdd); |
87 | + | |
83 | 88 | router.get('/del/:product', pageDel); |
84 | 89 | router.get('/delete/:product', pageDel); |
85 | 90 | router.get('/remove/:product', pageDel); |
91 | +router.get('/del', pageDel); | |
92 | +router.get('/delete', pageDel); | |
93 | +router.get('/remove', pageDel); |
package-lock.json