| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,6 +4,8 @@ const common = require('../common'); | |||
| 4 | 4 | const fixtures = require('../common/fixtures'); | |
| 5 | 5 | const assert = require('assert'); | |
| 6 | 6 | const fs = require('fs'); | |
| 7 | + const tmpdir = require('../common/tmpdir'); | ||
| 8 | + tmpdir.refresh(); | ||
| 7 | 9 | ||
| 8 | 10 | const url = fixtures.fileURL('a.js'); | |
| 9 | 11 | ||
@@ -80,3 +82,25 @@ if (common.isWindows) { | |||
| 80 | 82 | } | |
| 81 | 83 | ); | |
| 82 | 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 && !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 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments