@shieldsbetter/parse-if-match
v0.0.1
Published
Parse If-Match and If-None-Match headers
Downloads
1
Maintainers
Readme
parse-if-match
Parses If-Match
and If-None-Match
HTTP headers as specified in
RFC 7232, Sections 3.1 and 3.2.
TL;DR
const assert = require('assert');
const parseIfMatch = require('@shieldsbetter/parse-if-match');
assert.deepEqual(
parseIfMatch('"abc", W/"bcd"'),
[
{ eTag: 'abc', weak: false },
{ eTag: 'bcd', weak: true }
]);
assert.deepEqual(
parseIfMatch('*'),
[
{ star: true }
]);
try {
parseIfMatch('bad');
}
catch (e) {
assert.equal(e.code, 'PARSE_ERROR');
}
// RFC 7232 insists there be at least one ETag
try {
parseIfMatch('');
}
catch (e) {
assert.equal(e.code, 'PARSE_ERROR');
}