Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/internal/process/pre_execution.js
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ function readPolicyFromDisk() {
// no bare specifiers for now
let manifestURL;
if (require('path').isAbsolute(experimentalPolicy)) {
manifestURL = new URL(`file://${experimentalPolicy}`);
manifestURL = pathToFileURL(experimentalPolicy);
} else {
const cwdURL = pathToFileURL(process.cwd());
cwdURL.pathname += '/';
Expand Down
19 changes: 19 additions & 0 deletions test/parallel/test-policy-manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ common.requireNoPackageJSONAbove();

const assert = require('assert');
const { spawnSync } = require('child_process');
const { cpSync, rmSync } = require('fs');
const fixtures = require('../common/fixtures.js');
const tmpdir = require('../common/tmpdir.js');

{
const policyFilepath = fixtures.path('policy-manifest', 'invalid.json');
Expand All @@ -25,6 +27,23 @@ const fixtures = require('../common/fixtures.js');
assert.match(stderr, /pattern needs to have a single trailing "\*"/);
}

{
tmpdir.refresh();
const policyFilepath = tmpdir.resolve('file with % in its name.json');
cpSync(fixtures.path('policy-manifest', 'invalid.json'), policyFilepath);
const result = spawnSync(process.execPath, [
'--experimental-policy',
policyFilepath,
'./fhqwhgads.js',
]);

assert.notStrictEqual(result.status, 0);
const stderr = result.stderr.toString();
assert.match(stderr, /ERR_MANIFEST_INVALID_SPECIFIER/);
assert.match(stderr, /pattern needs to have a single trailing "\*"/);
rmSync(policyFilepath);
}

{
const policyFilepath = fixtures.path('policy-manifest', 'onerror-exit.json');
const result = spawnSync(process.execPath, [
Expand Down