diff --git a/src/node_modules.cc b/src/node_modules.cc index 4b522a91323c9f..7c1ef73c9445cc 100644 --- a/src/node_modules.cc +++ b/src/node_modules.cc @@ -340,12 +340,14 @@ void BindingData::GetNearestParentPackageJSON( ToNamespacedPath(realm->env(), &path_value); std::string path_value_str = path_value.ToString(); + auto path_value_u8str = + std::u8string(path_value_str.begin(), path_value_str.end()); if (slashCheck) { - path_value_str.push_back(kPathSeparator); + path_value_u8str.push_back(kPathSeparator); } auto package_json = - TraverseParent(realm, std::filesystem::path(path_value_str)); + TraverseParent(realm, std::filesystem::path(path_value_u8str)); if (package_json != nullptr) { args.GetReturnValue().Set(package_json->Serialize(realm)); @@ -366,12 +368,14 @@ void BindingData::GetNearestParentPackageJSONType( ToNamespacedPath(realm->env(), &path_value); std::string path_value_str = path_value.ToString(); + auto path_value_u8str = + std::u8string(path_value_str.begin(), path_value_str.end()); if (slashCheck) { - path_value_str.push_back(kPathSeparator); + path_value_u8str.push_back(kPathSeparator); } auto package_json = - TraverseParent(realm, std::filesystem::path(path_value_str)); + TraverseParent(realm, std::filesystem::path(path_value_u8str)); if (package_json == nullptr) { return;