Repository navigation
Releases
v2.0.0
The compatibility promise. require('stack-exchange-markdown-retriever').retrieveMarkdown(options, callback) builds the same request URL 1.1.7 built (https://api.stackexchange.com/2.2/..., the same filter and parameters) and calls back in the same order, (markdown, err), with the same markdown, null for a post that does not exist, and an error where 1.1.7 had one. The test suite checks this against 90 calls and 20 command-line runs recorded from the published 1.1.7 against a local test server, on both builds and every supported Node line. The exceptions are listed below; each one was a crash, a wrong answer or a way into other API methods: errors are StackExchangeError objects (API errors keep their message), an id that is not a post id throws, a callback that is not a function throws, a callback that throws is not called a second time, a plain-JSON response is read, and the command-line tool's -a works and its errors exit 1.
Changed (breaking)
- Needs Node 20 or later. The package has an
exportsmap, so deep imports such asstack-exchange-markdown-retriever/index.jsno longer resolve; import the package by its name. entityIdmust be a post id: a whole number, a string of digits, or such ids joined by;. Anything else (-1,1.5,'abc', an array,'../../users/1') throws aTypeErrorbefore any request. 1.1.7 put any value into the request path, so a crafted id could call other API methods.- Errors are
StackExchangeErrorobjects when the API answered with an error (same message as 1.1.7'sError, plusstatus,errorIdanderrorName) or with a body that is not its JSON (1.1.7 gave aTypeErrorabouttoStringfor an HTML error page, an empty or cut-off response). Network failures, timeouts and aborts are the platform's own errors. - A callback that is not a function throws a
TypeErrorbefore any request. 1.1.7 made the request, then crashed the process with an uncaughtTypeError. - Requests use the platform's
fetch. On Node,HTTPS_PROXYandNO_PROXYare read only when Node is told to (NODE_USE_ENV_PROXY=1or--use-env-proxy, on the Node lines that have them); 1.1.7'srequestalways read them. - A request that gets no answer fails after 30 seconds with a
TimeoutError(the newtimeoutoption;0turns it off). 1.1.7 waited for ever. - The command-line tool prints errors to stderr, without a stack trace, and exits 1. 1.1.7's
cli.jsprintednulland exited 0 for every error. A post that does not exist still printsnulland exits 0; so does a post without markdown (1.1.7 printedundefined).-sor-kwithout a value is an error (1.1.7 sentsite=trueorkey=true).
Fixed
- A callback that throws is called once; its exception still surfaces as an uncaught exception. 1.1.7 caught it and called the callback a second time with that exception as the error.
- A response that is plain JSON (a proxy that had already decompressed it) is read. 1.1.7 failed on anything that was not gzip or deflate data.
Zero padding after gzip data, and extra bytes after zlib data, are still read, as 1.1.7 read them. - The command-line tool's
-a/--answerfetches the answer. 1.1.7 ignored it and fetched the question with that id.
Added
- The command-line tool is installed as
stack-exchange-markdown-retriever(1.1.7's README documented it, but the package had nobin). It also takes--timeout <ms>,--helpand--version. - Called without a callback,
retrieveMarkdown(options)returns a Promise of the markdown (ornull), which rejects with the same errors the callback would get, argument errors included. timeoutandsignaloptions.StackExchangeError, exported by name.- ES module build with the named exports and a default export holding them; TypeScript declarations for both builds.
- Runs in Bun, Deno, workers and browsers: the library uses only
fetch,URL,AbortController,DecompressionStream,TextDecoderand timers. - Published from GitHub Actions through npm trusted publishing, with provenance.
Security
- No runtime dependencies. 1.x depends on the deprecated
requestpackage, whose tree carries critical and high advisories. - Ids are checked (see Changed): no path injection.
- A compressed response may expand to at most 64 MiB; a larger one fails with a
StackExchangeError. 1.1.7 had no limit.
v2.0.0-beta.1
The compatibility promise. require('stack-exchange-markdown-retriever').retrieveMarkdown(options, callback) builds the same request URL 1.1.7 built (https://api.stackexchange.com/2.2/..., the same filter and parameters) and calls back in the same order, (markdown, err), with the same markdown, null for a post that does not exist, and an error where 1.1.7 had one. The test suite checks this against 90 calls and 20 command-line runs recorded from the published 1.1.7 against a local test server, on both builds and every supported Node line. The exceptions are listed below; each one was a crash, a wrong answer or a way into other API methods: errors are StackExchangeError objects (API errors keep their message), an id that is not a post id throws, a callback that is not a function throws, a callback that throws is not called a second time, a plain-JSON response is read, and the command-line tool's -a works and its errors exit 1.
Changed (breaking)
- Needs Node 20 or later. The package has an
exportsmap, so deep imports such asstack-exchange-markdown-retriever/index.jsno longer resolve; import the package by its name. entityIdmust be a post id: a whole number, a string of digits, or such ids joined by;. Anything else (-1,1.5,'abc', an array,'../../users/1') throws aTypeErrorbefore any request. 1.1.7 put any value into the request path, so a crafted id could call other API methods.- Errors are
StackExchangeErrorobjects when the API answered with an error (same message as 1.1.7'sError, plusstatus,errorIdanderrorName) or with a body that is not its JSON (1.1.7 gave aTypeErrorabouttoStringfor an HTML error page, an empty or cut-off response). Network failures, timeouts and aborts are the platform's own errors. - A callback that is not a function throws a
TypeErrorbefore any request. 1.1.7 made the request, then crashed the process with an uncaughtTypeError. - Requests use the platform's
fetch. On Node,HTTPS_PROXYandNO_PROXYare read only when Node is told to (NODE_USE_ENV_PROXY=1or--use-env-proxy, on the Node lines that have them); 1.1.7'srequestalways read them. - A request that gets no answer fails after 30 seconds with a
TimeoutError(the newtimeoutoption;0turns it off). 1.1.7 waited for ever. - The command-line tool prints errors to stderr, without a stack trace, and exits 1. 1.1.7's
cli.jsprintednulland exited 0 for every error. A post that does not exist still printsnulland exits 0; so does a post without markdown (1.1.7 printedundefined).-sor-kwithout a value is an error (1.1.7 sentsite=trueorkey=true).
Fixed
- A callback that throws is called once; its exception still surfaces as an uncaught exception. 1.1.7 caught it and called the callback a second time with that exception as the error.
- A response that is plain JSON (a proxy that had already decompressed it) is read. 1.1.7 failed on anything that was not gzip or deflate data.
Zero padding after gzip data, and extra bytes after zlib data, are still read, as 1.1.7 read them. - The command-line tool's
-a/--answerfetches the answer. 1.1.7 ignored it and fetched the question with that id.
Added
- The command-line tool is installed as
stack-exchange-markdown-retriever(1.1.7's README documented it, but the package had nobin). It also takes--timeout <ms>,--helpand--version. - Called without a callback,
retrieveMarkdown(options)returns a Promise of the markdown (ornull), which rejects with the same errors the callback would get, argument errors included. timeoutandsignaloptions.StackExchangeError, exported by name.- ES module build with the named exports and a default export holding them; TypeScript declarations for both builds.
- Runs in Bun, Deno, workers and browsers: the library uses only
fetch,URL,AbortController,DecompressionStream,TextDecoderand timers. - Published from GitHub Actions through npm trusted publishing, with provenance.
Security
- No runtime dependencies. 1.x depends on the deprecated
requestpackage, whose tree carries critical and high advisories. - Ids are checked (see Changed): no path injection.
- A compressed response may expand to at most 64 MiB; a larger one fails with a
StackExchangeError. 1.1.7 had no limit.