test: fix invalid file: URL in test-fs-path-dir

PR-URL: https://github.com/nodejs/node/pull/55454
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
Antoine du Hamel 2024-10-21 02:27:11 +02:00 committed by GitHub
parent 11fbdd8c9d
commit 7e60b5e15b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5,7 +5,7 @@ const tmpdir = require('../common/tmpdir');
const assert = require('assert');
const path = require('path');
const fs = require('fs');
const URL = require('url').URL;
const { pathToFileURL } = require('url');
tmpdir.refresh();
@ -15,7 +15,7 @@ const nextFile = () => path.join(tmpdir.path, `file${fileCounter++}`);
const generateStringPath = (file, suffix = '') => file + suffix;
const generateURLPath = (file, suffix = '') =>
new URL('file://' + path.resolve(file) + suffix);
pathToFileURL(file + suffix);
const generateUint8ArrayPath = (file, suffix = '') =>
new Uint8Array(Buffer.from(file + suffix));