Skip to content

Fix npub normalization and improve test coverage#335

Open
23bsm038-Mahi wants to merge 2 commits intoshopstr-eng:mainfrom
23bsm038-Mahi:fix-npub-clean
Open

Fix npub normalization and improve test coverage#335
23bsm038-Mahi wants to merge 2 commits intoshopstr-eng:mainfrom
23bsm038-Mahi:fix-npub-clean

Conversation

@23bsm038-Mahi
Copy link
Copy Markdown
Contributor

Summary

Safely handle router.query.npub in marketplace routing.

Fix

  • added normalizeNpub helper
  • removed unsafe query handling
  • improved test coverage (malformed + happy path)

Impact

  • prevents runtime errors
  • ensures stable routing behavior

This PR contains only relevant changes.

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 4, 2026

@23bsm038-Mahi is attempting to deploy a commit to the shopstr-eng Team on Vercel.

A member of the Team first needs to authorize it.

@23bsm038-Mahi
Copy link
Copy Markdown
Contributor Author

Hi @arnavkirti @GautamBytes

I've created a clean follow-up PR (#335) addressing all review feedback:

  • extracted normalizeNpub helper
  • restored and updated tests
  • added malformed + happy-path test cases
  • removed unrelated changes

Would love your review on this one!

@23bsm038-Mahi
Copy link
Copy Markdown
Contributor Author

Hi @calvadev @GautamBytes

Just a quick update — this PR is now ready for review.

  • Extracted normalizeNpub helper for cleaner and safer handling
  • Restored and updated existing tests (no regressions)
  • Added focused tests for malformed npub handling
  • Added a happy-path test ensuring valid npub triggers nip19.decode

This PR is intentionally kept minimal and scoped only to this issue.

Please let me know if any further refinements are needed. Thanks!

Copy link
Copy Markdown
Contributor

@arnavkirti arnavkirti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@23bsm038-Mahi
Copy link
Copy Markdown
Contributor Author

I've updated the client-side npub decoding to ensure strict type validation (checking decoded.type and data type), removed unsafe casting, and kept the changes minimal.
Edge cases like malformed and query-array inputs are now safely handled.
This should now be production-ready and consistent with SSR behavior. Let me know if anything else is needed!

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