0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-worker-unsupported-path.js
Qingyu Deng 2a6e246478
worker: remove file extension check
Fixes: https://github.com/nodejs/node/issues/39124

PR-URL: https://github.com/nodejs/node/pull/39788
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2021-08-26 13:14:02 -07:00

44 lines
1.2 KiB
JavaScript

'use strict';
require('../common');
const path = require('path');
const assert = require('assert');
const { Worker } = require('worker_threads');
{
const expectedErr = {
code: 'ERR_WORKER_PATH',
name: 'TypeError'
};
const existingRelPathNoDot = path.relative('.', __filename);
assert.throws(() => { new Worker(existingRelPathNoDot); }, expectedErr);
assert.throws(() => { new Worker('relative_no_dot'); }, expectedErr);
assert.throws(() => { new Worker('file:///file_url'); }, expectedErr);
assert.throws(() => { new Worker('https://www.url.com'); }, expectedErr);
}
{
assert.throws(
() => { new Worker('file:///file_url'); },
/Wrap file:\/\/ URLs with `new URL`/
);
assert.throws(
() => { new Worker('data:text/javascript,'); },
/Wrap data: URLs with `new URL`/
);
assert.throws(
() => { new Worker('relative_no_dot'); },
// eslint-disable-next-line node-core/no-unescaped-regexp-dot
/^((?!Wrap file:\/\/ URLs with `new URL`).)*$/s
);
}
{
const expectedErr = {
code: 'ERR_INVALID_URL_SCHEME',
name: 'TypeError'
};
assert.throws(() => { new Worker(new URL('https://www.url.com')); },
expectedErr);
}