Skip to content

Fix basicauth for credentials requiring percent encoding#364

Merged
glynnbird merged 4 commits intomainfrom
fix-basicauth-percent-encoding
Feb 6, 2026
Merged

Fix basicauth for credentials requiring percent encoding#364
glynnbird merged 4 commits intomainfrom
fix-basicauth-percent-encoding

Conversation

@glynnbird
Copy link
Contributor

@glynnbird glynnbird commented Feb 6, 2026

Overview

As reported in #363, when the CouchDB URL includes a username & password and those credentials contain characters that need to be "percent encoded", then Nano's auth failed. (It did work fine for session auth).

After investigation, it turns out that new URL, the Node.js URL parser returns the username and password strings percent encoded. This meant that when these values were base64 encoded to become an Authorization header, they contained the wrong data (but only for usernames and passwords with "special characters"). See https://nodejs.org/api/url.html#urlusername & https://nodejs.org/api/url.html#urlpassword.

The solution is simple: just decodeURIComponent the values before base64 encoding them.

Testing recommendations

Automated test added.

GitHub issue number

Fixes issue #363

Checklist

  • Code is written and works correctly;
  • Changes are covered by tests;

@glynnbird glynnbird requested a review from janl February 6, 2026 11:02
@glynnbird glynnbird merged commit c757679 into main Feb 6, 2026
3 checks passed
@glynnbird glynnbird deleted the fix-basicauth-percent-encoding branch February 6, 2026 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants