Commit dafc9906a16e4ebcd535777be17bc164750a2932

Authored by Adhidarma Hadiwinoto
1 parent a636bde97c
Exists in master

uppercase and remove space on edit products

Showing 1 changed file with 10 additions and 7 deletions Side-by-side Diff

... ... @@ -87,13 +87,16 @@ function submitConfigEdit(req, res) {
87 87 req.body.newValue = sha256sum.digest('hex');
88 88  
89 89 } else if (req.scope == 'globals' && req.keyword == 'products' && req.body.newValue.trim()) {
90   - var products = req.body.newValue.split(',');
91   - var sortedProducts = products = aaa.sortProductsArray(products);
92   - req.body.newValue = sortedProducts.join(',');
93   - console.log('Unsorted products:');
94   - console.log(products);
95   - console.log('Sorted products:');
96   - console.log(sortedProducts);
  90 +
  91 + try {
  92 + var unsortedString = req.body.newValue.toUpperCase().replace(/ /g, '').trim();
  93 + var unsortedProducts = unsortedString.split(',');
  94 + var sortedProducts = aaa.sortProductsArray(unsortedProducts);
  95 + req.body.newValue = sortedProducts.join(',');
  96 + }
  97 + catch(e) {
  98 + console.log('Error sorting products');
  99 + }
97 100 }
98 101  
99 102 if (config[req.body.scope][req.body.keyword] != req.body.newValue.trim()) {