Repository navigation
fix: percent-decode the token in priompt:// connection URLs - #36
Merged
Merged
Conversation
MITU-DK
requested review from
guptadevik2003,
iamDyeus and
sujal-maheshwari2004
as code owners
November 15, 2026 17:15
sujal-maheshwari2004
approved these changes
Nov 18, 2026
sujal-maheshwari2004
left a comment
Member
There was a problem hiding this comment.
Tested locally; tests pass. Thanks!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
Fixes #27
What changed
parseUrl()now percent-decodes the token from apriompt://<token>@host:portURL, the same wayparseNatsUrl()already does.So
priompt://ab%2Bc%3D@localhost:8443now sendsBearer ab+c=instead ofBearer ab%2Bc%3D, which matches the Go CLI.I also handled a malformed token like
%ZZ. Without this,decodeURIComponentthrowsURIError: URI malformedand the client crashes with a message that doesn't say what's wrong.Now it throws a clear error ("the token in the connection URL is not valid percent-encoding"). The error message does not include the token, since it's a secret.
Unencoded tokens, URLs with no token, and plain
hostvalues behave the same as before.How I tested it
Ran
npm test: 16 pass, 0 fail.Added two tests in
test/token.test.js:an encoded token in PRIOMPT_URL is decoded: fails before the fix (Bearer ab%2Bc%3D) and passes after.a malformed percent-encoded token in PRIOMPT_URL throws a clear errorI also checked that the
urloption (not onlyPRIOMPT_URL) sends the decoded token.Checklist
good first issue: this is one of my first open-source contributions.