aboutsummaryrefslogtreecommitdiffstats
path: root/names/lnurl-params.js
blob: 9b04cbc70346e6e86346f5f0f62644bb3d342e39 (plain) (blame)
1
2
3
4
5
6
7
8
9
// Some LNURL clients (aqstr.com, 2026-12-04) append "?amount=…" to a callback
// that already has a query, so "cb?domain=coinos.io" arrives as
// "cb?domain=coinos.io?amount=21000": domain reads "coinos.io?amount=21000",
// the name is unknown and the payer gets a 404.
export function tolerantParams(search) {
  // a literal "?" inside a query is only ever this mistake: a real one in a
  // value arrives encoded (%3F). The first occurrence of a parameter wins.
  return new URLSearchParams(String(search || '').replace(/^\?/, '').replace(/\?/g, '&'));
}