Comment 9 for bug 1798187

Revision history for this message
Josh Stompro (u-launchpad-stompro-org) wrote :

It looks like for some reason, the regex that strips trailing spaces and commas, is also stripping off \r (carriage returns), but only for the barcodes that don't have trailing spaces..

Ohhh, it is that $ match. The $ is matching the \r, but if there are spaces or commas, it matches those and leaves the \r.

line = line.replace(/(.*?)($|\s.*|,.*)/,'$1');

Here is the barcode array before and after the regex.

Pre import barcodes:
Array(17) [ "35500004207930,\r", "\r", "33500012542726, \r", "35500004468045,\r", "\r", "33500012225165\r", "35500005727696 \r", "35500006028581\r", "35500004587208 \r", "35500003474093\r", … ]

Imported barcodes:
Array(12) [ "35500004207930\r", "33500012542726\r", "35500004468045\r", "33500012225165", "35500005727696\r", "35500006028581", "35500004587208\r", "35500003474093", "35500004587182\r", "35500006007197", … ]
app.js:300:13

I wonder of the original author of this was using files created in Linux, with no carriage returns. I just converted my file to unix EOL, and now it works fine as written. I think the code needs to handle both.

Josh