From bc0541f3e72fbac22fd032c7b858502c314a420c Mon Sep 17 00:00:00 2001 From: Deokjin Kim Date: Mon, 28 Nov 2022 10:47:22 +0900 Subject: [PATCH] remove `IDNA_` prefix from `enum idna_mode` --- src/node_i18n.cc | 9 ++++----- src/node_i18n.h | 8 ++++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/node_i18n.cc b/src/node_i18n.cc index 30436a6f7a4593..55088cb282c34f 100644 --- a/src/node_i18n.cc +++ b/src/node_i18n.cc @@ -648,7 +648,7 @@ int32_t ToASCII(MaybeStackBuffer* buf, UIDNA_CHECK_BIDI | // CheckBidi = true UIDNA_CHECK_CONTEXTJ | // CheckJoiners = true UIDNA_NONTRANSITIONAL_TO_ASCII; // Nontransitional_Processing - if (mode == idna_mode::IDNA_STRICT) { + if (mode == idna_mode::STRICT) { options |= UIDNA_USE_STD3_RULES; // UseSTD3ASCIIRules = beStrict // VerifyDnsLength = beStrict; // handled later @@ -696,15 +696,14 @@ int32_t ToASCII(MaybeStackBuffer* buf, info.errors &= ~UIDNA_ERROR_LEADING_HYPHEN; info.errors &= ~UIDNA_ERROR_TRAILING_HYPHEN; - if (mode != idna_mode::IDNA_STRICT) { + if (mode != idna_mode::STRICT) { // VerifyDnsLength = beStrict info.errors &= ~UIDNA_ERROR_EMPTY_LABEL; info.errors &= ~UIDNA_ERROR_LABEL_TOO_LONG; info.errors &= ~UIDNA_ERROR_DOMAIN_NAME_TOO_LONG; } - if (U_FAILURE(status) || - (mode != idna_mode::IDNA_LENIENT && info.errors != 0)) { + if (U_FAILURE(status) || (mode != idna_mode::LENIENT && info.errors != 0)) { len = -1; buf->SetLength(0); } else { @@ -742,7 +741,7 @@ static void ToASCII(const FunctionCallbackInfo& args) { Utf8Value val(env->isolate(), args[0]); // optional arg bool lenient = args[1]->BooleanValue(env->isolate()); - idna_mode mode = lenient ? idna_mode::IDNA_LENIENT : idna_mode::IDNA_DEFAULT; + idna_mode mode = lenient ? idna_mode::LENIENT : idna_mode::DEFAULT; MaybeStackBuffer buf; int32_t len = ToASCII(&buf, *val, val.length(), mode); diff --git a/src/node_i18n.h b/src/node_i18n.h index 33001383d5402c..7a4e81e099069d 100644 --- a/src/node_i18n.h +++ b/src/node_i18n.h @@ -44,13 +44,13 @@ void SetDefaultTimeZone(const char* tzid); enum class idna_mode { // Default mode for maximum compatibility. - IDNA_DEFAULT, + DEFAULT, // Ignore all errors in IDNA conversion, if possible. - IDNA_LENIENT, + LENIENT, // Enforce STD3 rules (UseSTD3ASCIIRules) and DNS length restrictions // (VerifyDnsLength). Corresponds to `beStrict` flag in the "domain to ASCII" // algorithm. - IDNA_STRICT + STRICT }; // Implements the WHATWG URL Standard "domain to ASCII" algorithm. @@ -58,7 +58,7 @@ enum class idna_mode { int32_t ToASCII(MaybeStackBuffer* buf, const char* input, size_t length, - idna_mode mode = idna_mode::IDNA_DEFAULT); + idna_mode mode = idna_mode::DEFAULT); // Implements the WHATWG URL Standard "domain to Unicode" algorithm. // https://url.spec.whatwg.org/#concept-domain-to-unicode