GeezerVison is showing github.com — fs: fix when path is buffer on fs.symlinkSync · nodejs/node@9b8596a
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: lib/internal/fs/utils.js +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -349,6 +349,7 @@ function preprocessSymlinkDestination(path, type, linkPath) { |
349 | 349 | // No preprocessing is needed on Unix. |
350 | 350 | return path; |
351 | 351 | } |
| 352 | + path = '' + path; |
352 | 353 | if (type === 'junction') { |
353 | 354 | // Junctions paths need to be absolute and \\?\-prefixed. |
354 | 355 | // A relative target is relative to the link's parent directory. |
@@ -360,7 +361,7 @@ function preprocessSymlinkDestination(path, type, linkPath) { |
360 | 361 | return pathModule.toNamespacedPath(path); |
361 | 362 | } |
362 | 363 | // Windows symlinks don't tolerate forward slashes. |
363 | | - return ('' + path).replace(/\//g, '\\'); |
| 364 | + return path.replace(/\//g, '\\'); |
364 | 365 | } |
365 | 366 |
|
366 | 367 | // Constructor for file stats. |
|
Collapse file
Copy file name to clipboardExpand all lines: test/parallel/test-fs-symlink.js +4Lines changed: 4 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -51,6 +51,10 @@ fs.symlink(linkData, linkPath, common.mustSucceed(() => { |
51 | 51 | fs.readlink(linkPath, common.mustSucceed((destination) => { |
52 | 52 | assert.strictEqual(destination, linkData); |
53 | 53 | })); |
| 54 | + |
| 55 | + tmpdir.refresh(); |
| 56 | + // Fixes: https://github.com/nodejs/node/issues/34514 |
| 57 | + fs.symlinkSync(Buffer.from(linkData), linkPath); |
54 | 58 | })); |
55 | 59 |
|
56 | 60 | // Test invalid symlink |
|