Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ 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' }
```

A header string from any other location can also be parsed for example a `Proxy-Authorization` header:

```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
Expand All @@ -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
Expand Down
Loading