mirror of
https://github.com/abrendan/MicDropMessages.git
synced 2025-08-25 22:12:02 +02:00
Initial commit
This commit is contained in:
29
node_modules/expect-ct/dist/index.js
generated
vendored
Normal file
29
node_modules/expect-ct/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
function parseMaxAge(option) {
|
||||
if (option === undefined) {
|
||||
return 0;
|
||||
}
|
||||
if (typeof option !== 'number' || option < 0) {
|
||||
throw new Error(option + " is not a valid value for maxAge. Please choose a positive integer.");
|
||||
}
|
||||
return option;
|
||||
}
|
||||
function getHeaderValueFromOptions(options) {
|
||||
options = options || {};
|
||||
var directives = [];
|
||||
if (options.enforce) {
|
||||
directives.push('enforce');
|
||||
}
|
||||
directives.push("max-age=" + parseMaxAge(options.maxAge));
|
||||
if (options.reportUri) {
|
||||
directives.push("report-uri=\"" + options.reportUri + "\"");
|
||||
}
|
||||
return directives.join(', ');
|
||||
}
|
||||
module.exports = function expectCt(options) {
|
||||
var headerValue = getHeaderValueFromOptions(options);
|
||||
return function expectCt(_req, res, next) {
|
||||
res.setHeader('Expect-CT', headerValue);
|
||||
next();
|
||||
};
|
||||
};
|
Reference in New Issue
Block a user