Skip to content

Commit

Permalink
Accept tabs inside dns.hosts and strip possible trailing comments
Browse files Browse the repository at this point in the history
Signed-off-by: DL6ER <[email protected]>
  • Loading branch information
DL6ER committed Feb 22, 2025
1 parent 37d36d5 commit 632dbcf
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions scripts/js/settings-dns-records.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,29 @@

function hostsDomain(data) {
// Split record in format IP NAME1 [NAME2 [NAME3 [NAME...]]]
const name = data.substring(data.indexOf(" ") + 1);
// We split both on spaces and tabs to support both formats
// Also, we remove any comments after the name(s)
const name = data.split(/[\t ]+/).slice(1).join(" ").split("#")[0].trim();
return name;
}

function hostsIP(data) {
// Split record in format IP NAME1 [NAME2 [NAME3 [NAME...]]]
const ip = data.substring(0, data.indexOf(" "));
// We split both on spaces and tabs to support both formats
const ip = data.split(/[\t ]+/)[0].trim();
return ip;
}

function CNAMEdomain(data) {
// Split record in format <cname>,<target>[,<TTL>]
const CNAMEarr = data.split(",");
return CNAMEarr[0];
return CNAMEarr[0].trim();
}

function CNAMEtarget(data) {
// Split record in format <cname>,<target>[,<TTL>]
const CNAMEarr = data.split(",");
return CNAMEarr[1];
return CNAMEarr[1].trim();
}

function CNAMEttl(data) {
Expand Down

0 comments on commit 632dbcf

Please sign in to comment.