Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXadillaX <i@2333.moe>2021-09-24 08:59:45 +0300
committerXadillaX <i@2333.moe>2021-09-26 11:57:47 +0300
commit0e561de643ab38c6a3b5c9912c2abd0b1527c14c (patch)
tree242bf31c9dca1f4f88bd5a4ab8301663209c43e7 /src/node_url.cc
parent281607d45394964f575b16034634295b3f596b7d (diff)
src: move `ToUSVString()` to node_util.cc
Since `toUSVString()` was exposed in `util` as a public API, not only for internal `url` any more. PR-URL: https://github.com/nodejs/node/pull/40204 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
Diffstat (limited to 'src/node_url.cc')
-rw-r--r--src/node_url.cc58
1 files changed, 0 insertions, 58 deletions
diff --git a/src/node_url.cc b/src/node_url.cc
index d78cb7a3e1c..14522fccb07 100644
--- a/src/node_url.cc
+++ b/src/node_url.cc
@@ -52,9 +52,6 @@ namespace {
// https://url.spec.whatwg.org/#eof-code-point
constexpr char kEOL = -1;
-// Used in ToUSVString().
-constexpr char16_t kUnicodeReplacementCharacter = 0xFFFD;
-
// https://url.spec.whatwg.org/#concept-host
class URLHost {
public:
@@ -160,14 +157,6 @@ enum url_error_cb_args {
#undef XX
};
-#define CHAR_TEST(bits, name, expr) \
- template <typename T> \
- bool name(const T ch) { \
- static_assert(sizeof(ch) >= (bits) / 8, \
- "Character must be wider than " #bits " bits"); \
- return (expr); \
- }
-
#define TWO_CHAR_STRING_TEST(bits, name, expr) \
template <typename T> \
bool name(const T ch1, const T ch2) { \
@@ -225,19 +214,8 @@ TWO_CHAR_STRING_TEST(8, IsWindowsDriveLetter,
TWO_CHAR_STRING_TEST(8, IsNormalizedWindowsDriveLetter,
(IsASCIIAlpha(ch1) && ch2 == ':'))
-// If a UTF-16 character is a low/trailing surrogate.
-CHAR_TEST(16, IsUnicodeTrail, (ch & 0xFC00) == 0xDC00)
-
-// If a UTF-16 character is a surrogate.
-CHAR_TEST(16, IsUnicodeSurrogate, (ch & 0xF800) == 0xD800)
-
-// If a UTF-16 surrogate is a low/trailing one.
-CHAR_TEST(16, IsUnicodeSurrogateTrail, (ch & 0x400) != 0)
-
-#undef CHAR_TEST
#undef TWO_CHAR_STRING_TEST
-
bool BitAt(const uint8_t a[], const uint8_t i) {
return !!(a[i >> 3] & (1 << (i & 7)));
}
@@ -1736,40 +1714,6 @@ void EncodeAuthSet(const FunctionCallbackInfo<Value>& args) {
String::NewFromUtf8(env->isolate(), output.c_str()).ToLocalChecked());
}
-void ToUSVString(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args);
- CHECK_GE(args.Length(), 2);
- CHECK(args[0]->IsString());
- CHECK(args[1]->IsNumber());
-
- TwoByteValue value(env->isolate(), args[0]);
-
- int64_t start = args[1]->IntegerValue(env->context()).FromJust();
- CHECK_GE(start, 0);
-
- for (size_t i = start; i < value.length(); i++) {
- char16_t c = value[i];
- if (!IsUnicodeSurrogate(c)) {
- continue;
- } else if (IsUnicodeSurrogateTrail(c) || i == value.length() - 1) {
- value[i] = kUnicodeReplacementCharacter;
- } else {
- char16_t d = value[i + 1];
- if (IsUnicodeTrail(d)) {
- i++;
- } else {
- value[i] = kUnicodeReplacementCharacter;
- }
- }
- }
-
- args.GetReturnValue().Set(
- String::NewFromTwoByte(env->isolate(),
- *value,
- NewStringType::kNormal,
- value.length()).ToLocalChecked());
-}
-
void DomainToASCII(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
CHECK_GE(args.Length(), 1);
@@ -1820,7 +1764,6 @@ void Initialize(Local<Object> target,
Environment* env = Environment::GetCurrent(context);
env->SetMethod(target, "parse", Parse);
env->SetMethodNoSideEffect(target, "encodeAuth", EncodeAuthSet);
- env->SetMethodNoSideEffect(target, "toUSVString", ToUSVString);
env->SetMethodNoSideEffect(target, "domainToASCII", DomainToASCII);
env->SetMethodNoSideEffect(target, "domainToUnicode", DomainToUnicode);
env->SetMethod(target, "setURLConstructor", SetURLConstructor);
@@ -1838,7 +1781,6 @@ void Initialize(Local<Object> target,
void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
registry->Register(Parse);
registry->Register(EncodeAuthSet);
- registry->Register(ToUSVString);
registry->Register(DomainToASCII);
registry->Register(DomainToUnicode);
registry->Register(SetURLConstructor);