@postalsys/ee-client 1.11.1 → 1.11.2
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/index.js +7 -4
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -134,15 +134,18 @@ function splitAddressField(value) {
|
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
function parseAddressEntry(entry) {
|
|
137
|
-
|
|
138
|
-
|
|
137
|
+
// "Name <address>": the address is between the last "<" and a closing ">" at the end.
|
|
138
|
+
// Found by index rather than a /^(.*)<([^>]*)>$/ match, which backtracks in quadratic
|
|
139
|
+
// time on a long run of "<" without the closing ">"
|
|
140
|
+
const open = entry.lastIndexOf('<');
|
|
141
|
+
if (open < 0 || !entry.endsWith('>') || entry.indexOf('>', open) !== entry.length - 1 || /[\n\r\u2028\u2029]/.test(entry.slice(0, open))) {
|
|
139
142
|
return { address: entry };
|
|
140
143
|
}
|
|
141
|
-
let name =
|
|
144
|
+
let name = entry.slice(0, open).trim();
|
|
142
145
|
if (name.length > 1 && name.startsWith('"') && name.endsWith('"')) {
|
|
143
146
|
name = name.slice(1, -1).replace(/\\(.)/g, '$1');
|
|
144
147
|
}
|
|
145
|
-
const address =
|
|
148
|
+
const address = entry.slice(open + 1, -1).trim();
|
|
146
149
|
return name ? { name, address } : { address };
|
|
147
150
|
}
|
|
148
151
|
|