From dec578bf91986f2e54b35a20cf2af4dab2a39e3e Mon Sep 17 00:00:00 2001 From: ucsurf <337280806+ucsurf@users.noreply.github.com> Date: Tue, 6 Oct 2026 19:53:15 +0300 Subject: [PATCH 1/2] docs: handle a missing Authorization header in README examples --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 84b476d..e024f38 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Pass a Basic auth header to the `parse()` method. If parsing fails ```js const { parse } = require('basic-auth'); -const user = parse(req.headers.authorization); +const user = parse(req.headers.authorization ?? ''); // => { name: 'something', pass: 'whatever' } ``` @@ -71,7 +71,7 @@ const compare = require('tsscmp'); // Create server const server = http.createServer(function (req, res) { - const credentials = parse(req.headers.authorization); + const credentials = parse(req.headers.authorization ?? ''); // Check credentials // The "check" function will typically be against your user store From 7fc82f77591636158d69aaa72896029a30f9fe07 Mon Sep 17 00:00:00 2001 From: ucsurf <337280806+ucsurf@users.noreply.github.com> Date: Wed, 7 Oct 2026 20:54:40 +0300 Subject: [PATCH 2/2] docs: apply review suggestion for Proxy-Authorization example --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e024f38..974c0a7 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ A header string from any other location can also be parsed for example a `Proxy- ```js const { parse } = require('basic-auth'); -const user = parse(req.getHeader('Proxy-Authorization')); +const user = parse(req.getHeader('Proxy-Authorization') ?? ''); ``` A credentials object can be formatted with `auth.format` as