mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
policy: canonicalize before resolving specifiers
PR-URL: https://github.com/nodejs/node/pull/37863 Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com> Co-authored-by: James M Snell <jasnell@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com>
This commit is contained in:
1 parent
d42bbe48c5
commit
bcb85adee6
12 files changed
+773
-352
No files matched your search
@@ -16,12 +16,13 @@ const dep = fixtures.path('policy', 'parent.js');
|
||||
'policy',
|
||||
'dependencies',
|
||||
'dependencies-redirect-policy.json');
|
||||
const { status } = spawnSync(
|
||||
const { status, stderr, stdout } = spawnSync(
|
||||
process.execPath,
|
||||
[
|
||||
'--experimental-policy', depPolicy, dep,
|
||||
]
|
||||
);
|
||||
console.log('%s\n%s', stderr, stdout);
|
||||
assert.strictEqual(status, 0);
|
||||
}
|
||||
{
|
||||
@@ -55,12 +56,13 @@ const dep = fixtures.path('policy', 'parent.js');
|
||||
'policy',
|
||||
'dependencies',
|
||||
'dependencies-wildcard-policy.json');
|
||||
const { status } = spawnSync(
|
||||
const { status, stderr, stdout } = spawnSync(
|
||||
process.execPath,
|
||||
[
|
||||
'--experimental-policy', depPolicy, dep,
|
||||
]
|
||||
);
|
||||
console.log('%s\n%s', stderr, stdout);
|
||||
assert.strictEqual(status, 0);
|
||||
}
|
||||
{
|
||||
@@ -76,6 +78,19 @@ const dep = fixtures.path('policy', 'parent.js');
|
||||
);
|
||||
assert.strictEqual(status, 1);
|
||||
}
|
||||
{
|
||||
const depPolicy = fixtures.path(
|
||||
'policy',
|
||||
'dependencies',
|
||||
'dependencies-missing-policy-default-true.json');
|
||||
const { status } = spawnSync(
|
||||
process.execPath,
|
||||
[
|
||||
'--experimental-policy', depPolicy, dep,
|
||||
]
|
||||
);
|
||||
assert.strictEqual(status, 0);
|
||||
}
|
||||
{
|
||||
const depPolicy = fixtures.path(
|
||||
'policy',
|
||||
@@ -107,5 +122,25 @@ const dep = fixtures.path('policy', 'parent.js');
|
||||
assert.match(
|
||||
`${stderr}`,
|
||||
/SyntaxError: Named export 'doesNotExist' not found\./,
|
||||
'Should give the real SyntaxError and position');
|
||||
new Error('Should give the real SyntaxError and position'));
|
||||
}
|
||||
{
|
||||
const depPolicy = fixtures.path(
|
||||
'policy',
|
||||
'dependencies',
|
||||
'dependencies-scopes-relative-specifier.json');
|
||||
const { status } = spawnSync(
|
||||
process.execPath,
|
||||
[
|
||||
'--experimental-policy',
|
||||
depPolicy,
|
||||
fixtures.path('policy', 'canonicalize.mjs'),
|
||||
]
|
||||
);
|
||||
assert.strictEqual(
|
||||
status,
|
||||
0,
|
||||
new Error(
|
||||
'policies should canonicalize specifiers by default prior to matching')
|
||||
);
|
||||
}
|
||||
@@ -38,6 +38,41 @@ const assert = require('assert');
|
||||
);
|
||||
}
|
||||
}
|
||||
{
|
||||
const manifest = new Manifest({
|
||||
scopes: {
|
||||
'': {
|
||||
dependencies: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
for (const href of baseURLs) {
|
||||
assert.strictEqual(
|
||||
manifest.getDependencyMapper(href).resolve('fs'),
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
{
|
||||
const manifest = new Manifest({
|
||||
scopes: {
|
||||
'': {
|
||||
dependencies: true
|
||||
},
|
||||
'file:': {
|
||||
cascade: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
for (const href of baseURLs) {
|
||||
assert.strictEqual(
|
||||
manifest.getDependencyMapper(href).resolve('fs'),
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
{
|
||||
const manifest = new Manifest({
|
||||
scopes: {
|
||||
|
||||
Reference in new issue
Block a user