mirror of
https://github.com/nodejs/node.git
synced 2025-05-22 13:56:10 +00:00

PR-URL: https://github.com/nodejs/node/pull/47335 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Beth Griggs <bethanyngriggs@gmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
35 lines
904 B
JavaScript
35 lines
904 B
JavaScript
'use strict';
|
|
|
|
const {
|
|
ObjectFreeze,
|
|
} = primordials;
|
|
|
|
const permission = internalBinding('permission');
|
|
const { validateString } = require('internal/validators');
|
|
const { isAbsolute, resolve } = require('path');
|
|
|
|
let experimentalPermission;
|
|
|
|
module.exports = ObjectFreeze({
|
|
__proto__: null,
|
|
isEnabled() {
|
|
if (experimentalPermission === undefined) {
|
|
const { getOptionValue } = require('internal/options');
|
|
experimentalPermission = getOptionValue('--experimental-permission');
|
|
}
|
|
return experimentalPermission;
|
|
},
|
|
has(scope, reference) {
|
|
validateString(scope, 'scope');
|
|
if (reference != null) {
|
|
// TODO: add support for WHATWG URLs and Uint8Arrays.
|
|
validateString(reference, 'reference');
|
|
if (!isAbsolute(reference)) {
|
|
return permission.has(scope, resolve(reference));
|
|
}
|
|
}
|
|
|
|
return permission.has(scope, reference);
|
|
},
|
|
});
|