is-firefox-order
Checks if http header order is Firefox
Usage
const express = require("express");
const isFirefoxOrder = require("is-firefox-order");
const port = 3000;
const app = express();
app.get("/", ({ headers }, res) => {
const are = isFirefoxOrder(headers) ? "are" : "are not";
res.send(`You ${are} firefox!`);
});
app.listen(port);
API
type Headers = Record<string, string> | string[] | Array<[string, string]>;
type IsFirefoxOrderOptions = {
areRawHeaders: boolean;
};
function IsFirefoxOrder(
headers: Headers,
options: IsFirefoxOrderOptions = { areRawHeaders = false }
): boolean;
export = IsFirefoxOrder;
headers
- one of:
- array of strings
["accept", "accept-language"];
- object of structure
[key: string]: string
{
'accept': '...',
'user-agent': '...'
}
- array with 2-length array of strings
[
["accept-encoding", "gzip"],
["accept", "*/*"],
];
options
: object that can have areRawHeaders
option if it should parse entries array such as:
[
"user-agent",
"this is invalid because there can be only one",
"User-Agent",
"curl/7.22.0",
"Host",
"127.0.0.1:8000",
"ACCEPT",
"*",
];
areRawHeaders
defaults to false
Test
npm test