-
-
Notifications
You must be signed in to change notification settings - Fork 132
Fix(npub): Do not parse npubs in links #2253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wasn't specified in the ticket because, at the time, I wasn't aware of it, but if there's only a link, it will still parse the npub in the link to show the nostr embed.
I consider this part of the issue.
51d9ca8
to
e039a31
Compare
e039a31
to
879f6b2
Compare
879f6b2
to
65bf754
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This removed all nostr embeds except for link posts.
This should be parsed as a nostr embed:
https://njump.me/npub1nsyte9neefm3jle7dg5gw6mhchxyk75a6f5dng70l4l3a2mx0nashqv2jk
This should be parsed as a link to njump:
npub1nsyte9neefm3jle7dg5gw6mhchxyk75a6f5dng70l4l3a2mx0nashqv2jk
This should stay a raw link:
https://npub1nsyte9neefm3jle7dg5gw6mhchxyk75a6f5dng70l4l3a2mx0nashqv2jk.nsite.lol
😅 This has got quite complex/confusing for me, let me have another look |
65bf754
to
82ba456
Compare
Ok, just tested using this link & previously discussed points. I think this solution should work. |
82ba456
to
f6cff35
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Nostr Link Embedding Logic Fails
The updated link processing logic introduces two regressions for Nostr links:
njump.me
Nostr links are unconditionally converted to embeds, disregarding thetextOnly
and!hasTextSibling
constraints. This results in unwanted embeds for links with surrounding text or custom link text.- Nostr links from other domains are explicitly prevented from becoming embeds, causing them to incorrectly render as autolinks even when they meet the
textOnly
and!hasTextSibling
criteria for embed conversion.
lib/rehype-sn.js#L94-L100
Lines 94 to 100 in f6cff35
if (embed?.provider === 'nostr' && host === 'njump.me') { | |
node.tagName = 'embed' | |
node.properties = { ...embed, src: href } | |
return | |
} | |
if (embed && embed.provider !== 'nostr' && textOnly && !hasTextSibling) { |
Was this report helpful? Give feedback by reacting with 👍 or 👎
Bugs as described by cursor are not described in spec. Either incorrect UX behaviour or undiscussed. I can confirm that everything discussed by human review on this PR has been addressed. edit: not even sure I'll qualify for the rewards based on the number of reviews introduced by cursor and spec changes. 🥲 |
Description
Add check to prevent parsing of npubs in links.
closes #2252
Screenshots
Before fix

After fix

Additional Context
Was anything unclear during your work on this PR? Anything we should definitely take a closer look at?
Checklist
Are your changes backward compatible? Please answer below:
Y
For example, a change is not backward compatible if you removed a GraphQL field or dropped a database column.
On a scale of 1-10 how well and how have you QA'd this change and any features it might affect? Please answer below:
10
For frontend changes: Tested on mobile, light and dark mode? Please answer below:
Did you introduce any new environment variables? If so, call them out explicitly here:
N