Skip to content

Commit

Permalink
Merge pull request #46 from elgs/fix-error-when-no-soa
Browse files Browse the repository at this point in the history
Fix error when no soa
  • Loading branch information
elgs authored May 18, 2023
2 parents 2ca5ffd + 42bf75e commit 6c82386
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
9 changes: 5 additions & 4 deletions lib/zonefile-node-legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,14 +271,15 @@ let removeComments = function (text) {
};

let flatten = function (text) {
let soa;
let re = /SOA[\s\S]*?\([\s\S]*?\)/gim;
let match = re.exec(text);
if (match !== null) {
soa = match[0].replace(/\s+/gm, ' ');
let soa = match[0].replace(/\s+/gm, ' ');
soa = soa.replace(/\(|\)/gim, ' ');
return text.substring(0, match.index) + soa + text.substring(match.index + match[0].length);
} else {
return text;
}
soa = soa.replace(/\(|\)/gim, ' ');
return text.substring(0, match.index) + soa + text.substring(match.index + match[0].length);
};

let normalizeRR = function (rr) {
Expand Down
9 changes: 5 additions & 4 deletions lib/zonefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,14 +270,15 @@ let removeComments = function (text) {
};

let flatten = function (text) {
let soa;
let re = /SOA[\s\S]*?\([\s\S]*?\)/gim;
let match = re.exec(text);
if (match !== null) {
soa = match[0].replace(/\s+/gm, ' ');
let soa = match[0].replace(/\s+/gm, ' ');
soa = soa.replace(/\(|\)/gim, ' ');
return text.substring(0, match.index) + soa + text.substring(match.index + match[0].length);
} else {
return text;
}
soa = soa.replace(/\(|\)/gim, ' ');
return text.substring(0, match.index) + soa + text.substring(match.index + match[0].length);
};

let normalizeRR = function (rr) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dns-zonefile",
"version": "0.3.1",
"version": "0.3.2",
"description": "A DNS zone file parser and generator.",
"main": "./lib/zonefile.js",
"types": "./lib/zonefile.d.ts",
Expand Down

0 comments on commit 6c82386

Please sign in to comment.