@shieldsbetter/parse-if-match

0.0.1 • Public • Published

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');
}

/@shieldsbetter/parse-if-match/

    Package Sidebar

    Install

    npm i @shieldsbetter/parse-if-match

    Weekly Downloads

    0

    Version

    0.0.1

    License

    ISC

    Unpacked Size

    9.79 kB

    Total Files

    5

    Last publish

    Collaborators

    • shieldsbetter