@sdxc/zone-file 2026.10.9 → 2026.10.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/names.js +8 -3
- package/dist/parse-record-data.js +6 -3
- package/dist/ttl.js +18 -3
- package/package.json +2 -2
package/dist/names.js
CHANGED
|
@@ -161,7 +161,12 @@ export function relativeName(name, origin) {
|
|
|
161
161
|
* @example absoluteName("mx.example.com") // "mx.example.com."
|
|
162
162
|
*/
|
|
163
163
|
export function absoluteName(name) {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
164
|
+
if (name === ".")
|
|
165
|
+
return name;
|
|
166
|
+
if (!name.endsWith("."))
|
|
167
|
+
return `${name}.`;
|
|
168
|
+
let backslashes = 0;
|
|
169
|
+
for (let index = name.length - 2; index >= 0 && name[index] === "\\"; index--)
|
|
170
|
+
backslashes++;
|
|
171
|
+
return backslashes % 2 === 0 ? name : `${name}.`;
|
|
167
172
|
}
|
|
@@ -79,7 +79,7 @@ function parsePresentation(type, value) {
|
|
|
79
79
|
return success({ type, text: strings.data.join(""), strings: strings.data });
|
|
80
80
|
}
|
|
81
81
|
case "CAA": {
|
|
82
|
-
let match = /^(\d+)\s+([A-Za-z0-9]+)\s+(
|
|
82
|
+
let match = /^(\d+)\s+([A-Za-z0-9]+)\s+(\S.*)$/.exec(value);
|
|
83
83
|
let flags = readNumber(match?.[1], 0xff);
|
|
84
84
|
if (!match || flags === null || match[2] === undefined || match[3] === undefined)
|
|
85
85
|
return invalid(type, value);
|
|
@@ -137,9 +137,12 @@ function parsePresentation(type, value) {
|
|
|
137
137
|
return success({ type, data: value });
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
|
-
/**
|
|
140
|
+
/**
|
|
141
|
+
* Decodes RFC 3597 generic data (`\# <length> <hex>`) and reads the octets for the type. The
|
|
142
|
+
* length is the whole leading digit run, so the hex after it starts at whitespace or a letter.
|
|
143
|
+
*/
|
|
141
144
|
function parseGeneric(type, value) {
|
|
142
|
-
let match = /^\\#\s+(\d+)((
|
|
145
|
+
let match = /^\\#\s+(\d+)((?:[\sa-fA-F][\s0-9a-fA-F]*)?)$/.exec(value);
|
|
143
146
|
if (!match)
|
|
144
147
|
return invalid(type, value);
|
|
145
148
|
let hex = (match[2] ?? "").replace(/\s+/g, "");
|
package/dist/ttl.js
CHANGED
|
@@ -24,8 +24,23 @@ export function looksLikeTtl(field) {
|
|
|
24
24
|
export function readTtl(field) {
|
|
25
25
|
if (!looksLikeTtl(field))
|
|
26
26
|
return null;
|
|
27
|
-
let seconds = /^\d+$/.test(field)
|
|
28
|
-
? Number(field)
|
|
29
|
-
: Array.from(field.matchAll(/(\d+)([smhdw])/gi)).reduce((total, [, amount, unit]) => total + Number(amount) * (UNIT_SECONDS[(unit ?? "s").toLowerCase()] ?? 1), 0);
|
|
27
|
+
let seconds = /^\d+$/.test(field) ? Number(field) : sumUnits(field);
|
|
30
28
|
return seconds <= MAX_TTL ? seconds : null;
|
|
31
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Adds up a unit-form TTL already checked by `looksLikeTtl`, in one pass over the field so its
|
|
32
|
+
* cost stays linear in the field's length.
|
|
33
|
+
*/
|
|
34
|
+
function sumUnits(field) {
|
|
35
|
+
let total = 0;
|
|
36
|
+
let amount = "";
|
|
37
|
+
for (let char of field) {
|
|
38
|
+
if (char >= "0" && char <= "9") {
|
|
39
|
+
amount += char;
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
total += Number(amount) * (UNIT_SECONDS[char.toLowerCase()] ?? 1);
|
|
43
|
+
amount = "";
|
|
44
|
+
}
|
|
45
|
+
return total;
|
|
46
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sdxc/zone-file",
|
|
3
|
-
"version": "2026.10.
|
|
3
|
+
"version": "2026.10.10",
|
|
4
4
|
"description": "Read and write RFC 1035 DNS zone files, with the record data codec for every typed record",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@sdxc/result": "2026.10.6"
|
|
12
12
|
},
|
|
13
|
-
"gitHead": "
|
|
13
|
+
"gitHead": "b61f19c59866708a2d89a5a8f4655ebbc16941b0",
|
|
14
14
|
"publishConfig": {
|
|
15
15
|
"access": "public"
|
|
16
16
|
},
|