8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
node:fs
1 parent 2b11910 commit 34c1741Copy full SHA for 34c1741
test/parallel/test-fs-whatwg-url.js
@@ -4,6 +4,8 @@ const common = require('../common');
4
const fixtures = require('../common/fixtures');
5
const assert = require('assert');
6
const fs = require('fs');
7
+const tmpdir = require('../common/tmpdir');
8
+tmpdir.refresh();
9
10
const url = fixtures.fileURL('a.js');
11
@@ -80,3 +82,25 @@ if (common.isWindows) {
80
82
}
81
83
);
84
85
+
86
+// Test that strings are interpreted as paths and not as URL
87
+// Can't use process.chdir in Workers
88
+// Please avoid testing fs.rmdir('file:') or using it as cleanup
89
+if (common.isMainThread &&am 9EDF p; !common.isWindows) {
90
+ const oldCwd = process.cwd();
91
+ process.chdir(tmpdir.path);
92
93
+ for (let slashCount = 0; slashCount < 9; slashCount++) {
94
+ const slashes = '/'.repeat(slashCount);
95
96
+ const dirname = `file:${slashes}thisDirectoryWasMadeByFailingNodeJSTestSorry/subdir`;
97
+ fs.mkdirSync(dirname, { recursive: true });
98
+ fs.writeFileSync(`${dirname}/file`, `test failed with ${slashCount} slashes`);
99
100
+ const expected = fs.readFileSync(tmpdir.resolve(dirname, 'file'));
101
+ const actual = fs.readFileSync(`${dirname}/file`);
102
+ assert.deepStrictEqual(actual, expected);
103
+ }
104
105
+ process.chdir(oldCwd);
106
+}