@@ -269,7 +269,7 @@ std::string PathResolve(Environment* env, |
269 | 269 | void ToNamespacedPath(Environment* env, BufferValue* path) { |
270 | 270 | #ifdef _WIN32 |
271 | 271 | if (path->length() == 0) return; |
272 | | - auto resolved_path = node::PathResolve(env, {path->ToStringView()}); |
| 272 | + std::string resolved_path = node::PathResolve(env, {path->ToStringView()}); |
273 | 273 | if (resolved_path.size() <= 2) { |
274 | 274 | return; |
275 | 275 | } |
@@ -282,14 +282,13 @@ void ToNamespacedPath(Environment* env, BufferValue* path) { |
282 | 282 | if (resolved_path[2] != '?' && resolved_path[2] != '.') { |
283 | 283 | // Matched non-long UNC root, convert the path to a long UNC path |
284 | 284 | std::string_view unc_prefix = R"(\\?\UNC\)"; |
285 | | - std::string_view resolved_path2 = resolved_path.substr(2); |
286 | | - size_t new_length = unc_prefix.size() + resolved_path2.size(); |
| 285 | + size_t new_length = unc_prefix.size() + resolved_path.size() - 2; |
287 | 286 | path->AllocateSufficientStorage(new_length + 1); |
288 | 287 | path->SetLength(new_length); |
289 | 288 | memcpy(path->out(), unc_prefix.data(), unc_prefix.size()); |
290 | 289 | memcpy(path->out() + unc_prefix.size(), |
291 | 290 | resolved_path.c_str() + 2, |
292 | | - resolved_path2.size() + 1); |
| 291 | + resolved_path.size() - 2 + 1); |
293 | 292 | return; |
294 | 293 | } |
295 | 294 | } |
|