-
Notifications
You must be signed in to change notification settings - Fork 167
Better sanitizePaymentRequest #113
Conversation
|
|
||
| export const sanitizePaymentRequest = (pr) => { | ||
| return pr.replace(prefix, '') | ||
| return pr.replace(/lightning:(\/\/)?/g, '') |
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.
Can you add comment explaining the possible prefix matches?
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.
I just found the two above (lightning: and lightning://) so they are the only possible matches
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.
I meant to add it as a comment in the code above that line, something like:
// Payment requests should start with either lightning: or lightning://
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.
oh sorry for my misunderstanding. I'll do it rn
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.
Is there any documentation for the lightning:// prefix? I could only find https://github.com/lightningnetwork/lightning-rfc/blob/master/11-payment-encoding.md which says not to use lightning://
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.
Our usage of the lightning:// prefix actually predates BOLT 11 itself.
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.
Thanks for the PR!
A more direct change is to modify the definition of prefix here:
| const prefix = 'lightning://' |
No regex required!
|
Thanks @BeeCodiing and @bulenttastan! This was completed as a followup to PR #107. |
Really simple but functional. I noticed that starblocks's payment invoice uses
lightning:and notlightning://(the only one specified by the function) so I added support for that prefix too by using regex.