diff options
Diffstat (limited to 'names/lnurl-params.test.js')
| -rw-r--r-- | names/lnurl-params.test.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/names/lnurl-params.test.js b/names/lnurl-params.test.js new file mode 100644 index 0000000..c198853 --- /dev/null +++ b/names/lnurl-params.test.js @@ -0,0 +1,22 @@ +// bun test names/lnurl-params.test.js +import { test, expect } from 'bun:test'; +import { tolerantParams } from './lnurl-params.js'; + +const p = (q) => tolerantParams(new URL('https://x/lnurlp/a/cb' + q).search); + +test('a well-formed callback is read as is', () => { + const r = p('?domain=coinos.io&amount=21000&comment=hi%3F'); + expect(r.get('domain')).toBe('coinos.io'); + expect(r.get('amount')).toBe('21000'); + expect(r.get('comment')).toBe('hi?'); +}); +test('a second ? (amount appended with ? instead of &) still finds the name and amount', () => { + const r = p('?domain=coinos.io?amount=21000&nostr=%7B%7D'); + expect(r.get('domain')).toBe('coinos.io'); + expect(r.get('amount')).toBe('21000'); + expect(r.get('nostr')).toBe('{}'); +}); +test("parameters already in the URL aren't overridden", () => { + const r = p('?amount=5000&domain=coinos.io?amount=21000'); + expect(r.get('amount')).toBe('5000'); +}); |
