(label, {
checkHyphens,
checkBidi,
checkJoiners,
transitionalProcessing,
useSTD3ASCIIRules,
isBidi
})
| 3213 | return processed; |
| 3214 | } |
| 3215 | function validateLabel(label, { |
| 3216 | checkHyphens, |
| 3217 | checkBidi, |
| 3218 | checkJoiners, |
| 3219 | transitionalProcessing, |
| 3220 | useSTD3ASCIIRules, |
| 3221 | isBidi |
| 3222 | }) { |
| 3223 | if (label.length === 0) { |
| 3224 | return true; |
| 3225 | } |
| 3226 | if (label.normalize("NFC") !== label) { |
| 3227 | return false; |
| 3228 | } |
| 3229 | const codePoints = Array.from(label); |
| 3230 | if (checkHyphens) { |
| 3231 | if (codePoints[2] === "-" && codePoints[3] === "-" || (label.startsWith("-") || label.endsWith("-"))) { |
| 3232 | return false; |
| 3233 | } |
| 3234 | } |
| 3235 | if (!checkHyphens) { |
| 3236 | if (label.startsWith("xn--")) { |
| 3237 | return false; |
| 3238 | } |
| 3239 | } |
| 3240 | if (label.includes(".")) { |
| 3241 | return false; |
| 3242 | } |
| 3243 | if (regexes.combiningMarks.test(codePoints[0])) { |
| 3244 | return false; |
| 3245 | } |
| 3246 | for (const ch of codePoints) { |
| 3247 | const codePoint = ch.codePointAt(0); |
| 3248 | const [status] = findStatus(codePoint); |
| 3249 | if (transitionalProcessing) { |
| 3250 | if (status !== STATUS_MAPPING.valid) { |
| 3251 | return false; |
| 3252 | } |
| 3253 | } else if (status !== STATUS_MAPPING.valid && status !== STATUS_MAPPING.deviation) { |
| 3254 | return false; |
| 3255 | } |
| 3256 | if (useSTD3ASCIIRules && codePoint <= 127) { |
| 3257 | if (!/^(?:[a-z]|[0-9]|-)$/u.test(ch)) { |
| 3258 | return false; |
| 3259 | } |
| 3260 | } |
| 3261 | } |
| 3262 | if (checkJoiners) { |
| 3263 | let last = 0; |
| 3264 | for (const [i3, ch] of codePoints.entries()) { |
| 3265 | if (ch === "\u200C" || ch === "\u200D") { |
| 3266 | if (i3 > 0) { |
| 3267 | if (regexes.combiningClassVirama.test(codePoints[i3 - 1])) { |
| 3268 | continue; |
| 3269 | } |
| 3270 | if (ch === "\u200C") { |
| 3271 | const next = codePoints.indexOf("\u200C", i3 + 1); |
| 3272 | const test2 = next < 0 ? codePoints.slice(last) : codePoints.slice(last, next); |
no test coverage detected
searching dependent graphs…