
Research
/Security News
Intercom’s npm Package Compromised in Ongoing Mini Shai-Hulud Worm Attack
Compromised intercom-client@7.0.4 npm package is tied to the ongoing Mini Shai-Hulud worm attack targeting developer and CI/CD secrets.
header-range-parser
Advanced tools

Range header field parser. Fork of a̶b̶a̶n̶d̶o̶n̶e̶d̶ range-parser.
npm install header-range-parser
const {
ERROR_INVALID_ARGUMENT,
ERROR_STRING_IS_NOT_HEADER,
ERROR_UNSATISFIABLE_RESULT,
parseRange,
} = require("header-range-parser");
import {
ERROR_INVALID_ARGUMENT,
ERROR_STRING_IS_NOT_HEADER,
ERROR_UNSATISFIABLE_RESULT,
ResultInvalid,
ResultUnsatisfiable,
ResultWrongArgument,
parseRange,
} from "header-range-parser";
import {
Result, Ranges, parseRange, Options,
} from "header-range-parser";
declare function parseRange(
size: number, header: string, options?: Options,
): Ranges | Result;
| Parameter | Type | Description |
|---|---|---|
size | number | Required. Size in bytes. |
header | string | Required. String containing header. |
options | object | Optional options: combine (bool), throwError (bool). |
Parse the given header string where size is the size of the selected
representation that is to be partitioned into sub-ranges. An array of sub-ranges
will be returned or negative numbers indicating an error parsing.
-1 or ERROR_UNSATISFIABLE_RESULT or ResultUnsatisfiable signals an unsatisfiable range
-2 or ERROR_STRING_IS_NOT_HEADER or ResultInvalid signals a malformed header string
-3 or ERROR_INVALID_ARGUMENT or ResultWrongArgument invalid parameters
// parse header from request
const subRanges = parseRange(
size,
request.headers.range,
);
// the type of the subranges
if (subRanges.type === "bytes") {
// the ranges
subRanges.forEach((range) => {
// do something
// with range.start
// and range.end
});
}
These properties are accepted in the options object.
Specifies if overlapping and adjacent sub-ranges should be combined, defaults to false.
When true, ranges will be combined and returned as if they were specified that way in the header.
Throw or suppress errors. Defaults to true.
parseRange(
100,
"bytes=50-55,0-10,5-10,56-60",
{
combine: true,
throwError: false,
});
// [
// { start: 0, end: 10 },
// { start: 50, end: 60 }
// ]
FAQs
Range header field string parser.
The npm package header-range-parser receives a total of 53,206 weekly downloads. As such, header-range-parser popularity was classified as popular.
We found that header-range-parser demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Compromised intercom-client@7.0.4 npm package is tied to the ongoing Mini Shai-Hulud worm attack targeting developer and CI/CD secrets.

Research
Socket detected a malicious supply chain attack on PyPI package lightning versions 2.6.2 and 2.6.3, which execute credential-stealing malware on import.

Research
A brand-squatted TanStack npm package used postinstall scripts to steal .env files and exfiltrate developer secrets to an attacker-controlled endpoint.