Initial commit

This commit is contained in:
2026-08-30 15:23:57 +02:00
commit dab5679098
1293 changed files with 240952 additions and 0 deletions
+54
View File
@@ -0,0 +1,54 @@
/*!
* negotiator
* Copyright(c) 2026 Blake Embrey
* MIT Licensed
*/
'use strict';
var contentType = require('content-type');
/**
* Module exports.
* @private
*/
module.exports = parseAccept;
/**
* Parse an Accept-style header.
* @private
*/
function parseAccept(header) {
var values = [];
var index = 0;
while (index < header.length) {
var start = skipOptionalWhitespace(header, index);
var parsed = contentType.parse(header, { comma: true, start: start });
// `content-type` normalizes the type, but accept methods return original casing.
parsed.type = header.slice(start, start + parsed.type.length);
values.push(parsed);
index = parsed.index + 1;
}
return values;
}
/**
* Skip optional whitespace.
* @private
*/
function skipOptionalWhitespace(header, index) {
var cursor = index;
while (header.charCodeAt(cursor) === 0x20 || header.charCodeAt(cursor) === 0x09) {
cursor++;
}
return cursor;
}