Skip to content

Commit

Permalink
support comments (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
massimocandela committed Oct 16, 2022
1 parent 799ef35 commit 123b163
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/index.js
Expand Up @@ -32,7 +32,7 @@ const rd = readline.createInterface({
rd.on('line', function(line) {
const errors = validator.fromLine(line);

if (errors.length) {
if (errors && errors.length) {
console.log(`${line} Error: ${errors.join(", ")}`);
}
});
5 changes: 4 additions & 1 deletion src/validator.js
Expand Up @@ -3,7 +3,10 @@ import IsoAbstraction from "./isoAbstraction";
const iso = new IsoAbstraction();

const fromLine = (line) => {
return fromArray(line.split(","));
const trimmedLine = line.trim();
if (!!trimmedLine && trimmedLine.length > 0 && !trimmedLine.startsWith("#")) {
return fromArray(trimmedLine.split(","));
}
};

const fromArray = ([prefix, country, region, city, zip]) => {
Expand Down

0 comments on commit 123b163

Please sign in to comment.