Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixup! module,win: fix long path resolve
  • Loading branch information
huseyinacacak-janea committed Jul 16, 2024
commit 0e2c73986d4328341e50d1b2ab72197289b9f1ae
8 changes: 4 additions & 4 deletions src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3096,9 +3096,9 @@ void BindingData::LegacyMainResolve(const FunctionCallbackInfo<Value>& args) {

for (int i = 0; i < legacy_main_extensions_with_main_end; i++) {
file_path = *initial_file_path + std::string(legacy_main_extensions[i]);
// TODO(anonrig): Remove this when ToNamespacedPath supports std::string
Local<Value> local_file_path =
Comment thread
anonrig marked this conversation as resolved.
Resolved
Buffer::Copy(
env->isolate(), file_path.c_str(), file_path.size())
Buffer::Copy(env->isolate(), file_path.c_str(), file_path.size())
.ToLocalChecked();
BufferValue buff_file_path(isolate, local_file_path);
ToNamespacedPath(env, &buff_file_path);
Expand Down Expand Up @@ -3139,9 +3139,9 @@ void BindingData::LegacyMainResolve(const FunctionCallbackInfo<Value>& args) {
i < legacy_main_extensions_package_fallback_end;
i++) {
file_path = *initial_file_path + std::string(legacy_main_extensions[i]);
// TODO(anonrig): Remove this when ToNamespacedPath supports std::string
Local<Value> local_file_path =
Buffer::Copy(
env->isolate(), file_path.c_str(), file_path.size())
Buffer::Copy(env->isolate(), file_path.c_str(), file_path.size())
.ToLocalChecked();
BufferValue buff_file_path(isolate, local_file_path);
ToNamespacedPath(env, &buff_file_path);
Expand Down
14 changes: 6 additions & 8 deletions src/node_modules.cc
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ void BindingData::ReadPackageJSON(const FunctionCallbackInfo<Value>& args) {
path.ToStringView());

ToNamespacedPath(realm->env(), &path);
auto package_json =
GetPackageJSON(realm, path.ToString(), is_esm ? &error_context : nullptr);
auto package_json = GetPackageJSON(
realm, path.ToStringView(), is_esm ? &error_context : nullptr);

if (package_json == nullptr) {
return;
Expand Down Expand Up @@ -322,9 +322,8 @@ void BindingData::GetNearestParentPackageJSON(
BufferValue path_value(realm->isolate(), args[0]);
// Check if the path has a trailing slash. If so, add it after
// ToNamespacedPath() as it will be deleted by ToNamespacedPath()
bool slashCheck = !path_value.ToString().empty() &&
path_value.ToStringView().ends_with(
std::filesystem::path::preferred_separator);
bool slashCheck = path_value.ToStringView().ends_with(
std::filesystem::path::preferred_separator);

ToNamespacedPath(realm->env(), &path_value);

Expand All @@ -350,9 +349,8 @@ void BindingData::GetNearestParentPackageJSONType(
BufferValue path_value(realm->isolate(), args[0]);
// Check if the path has a trailing slash. If so, add it after
// ToNamespacedPath() as it will be deleted by ToNamespacedPath()
bool slashCheck = !path_value.ToString().empty() &&
path_value.ToStringView().ends_with(
std::filesystem::path::preferred_separator);
bool slashCheck = path_value.ToStringView().ends_with(
std::filesystem::path::preferred_separator);

ToNamespacedPath(realm->env(), &path_value);

Expand Down