@@ -508,6 +508,41 @@ describe('Helpers Unit Tests', () => {
508508 } ) ;
509509 } ) ;
510510
511+ describe ( 'isValidUri()' , ( ) => {
512+ it ( 'should accept bitcoin uri' , ( ) => {
513+ const uri = 'bitcoin:rfu4i1Mo2NF7TQsN9bMVLFSojSzcyQCEH5' ;
514+ expect ( helpers . isValidUri ( uri ) , 'to be' , true ) ;
515+ } ) ;
516+
517+ it ( 'should accept lightning uri' , ( ) => {
518+ const uri =
519+ 'lightning:lntb1500n1pdn2e0app5wlyxzspccpfvqmrtfr8p487xcch4hxtu2u0qzcke6mzpv222w8usdpa2fjkzep6ypxx2ap8wvs8qmrp0ysxzgrvd9nksarwd9hxwgrwv468wmmjdvsxwcqzysmr9jxv06zx53cyqa0sqntehy5tyrqu064xvw00qjep5f9gw57qcqp6qnpqyuprh90aqzfyf9ypq8uth7qte5ecjq0fng3y47mywwkfqq3megny' ;
520+ expect ( helpers . isValidUri ( uri ) , 'to be' , true ) ;
521+ } ) ;
522+
523+ it ( 'should reject bitcoin address' , ( ) => {
524+ const uri = 'rfu4i1Mo2NF7TQsN9bMVLFSojSzcyQCEH5' ;
525+ expect ( helpers . isValidUri ( uri ) , 'to be' , false ) ;
526+ } ) ;
527+
528+ it ( 'should reject lightning invoice' , ( ) => {
529+ const uri =
530+ 'lntb1500n1pdn2e0app5wlyxzspccpfvqmrtfr8p487xcch4hxtu2u0qzcke6mzpv222w8usdpa2fjkzep6ypxx2ap8wvs8qmrp0ysxzgrvd9nksarwd9hxwgrwv468wmmjdvsxwcqzysmr9jxv06zx53cyqa0sqntehy5tyrqu064xvw00qjep5f9gw57qcqp6qnpqyuprh90aqzfyf9ypq8uth7qte5ecjq0fng3y47mywwkfqq3megny' ;
531+ expect ( helpers . isValidUri ( uri ) , 'to be' , false ) ;
532+ } ) ;
533+
534+ it ( 'should reject invalid bitcoin uri' , ( ) => {
535+ const uri = 'bitcoin:/INVALID/rfu4i1Mo2NF7TQsN9bMVLFSojSzcyQCEH5' ;
536+ expect ( helpers . isValidUri ( uri ) , 'to be' , false ) ;
537+ } ) ;
538+
539+ it ( 'should mitigate xss' , ( ) => {
540+ const uri =
541+ 'bitcoin:rfu4i1Mo2NF7T<script>alert("XSS")</script>QsN9bMVLFSojSzcyQCEH5' ;
542+ expect ( helpers . isValidUri ( uri ) , 'to be' , false ) ;
543+ } ) ;
544+ } ) ;
545+
511546 describe ( 'checkHttpStatus()' , ( ) => {
512547 it ( 'should throw error for 500' , ( ) => {
513548 const response = { status : 500 , statusText : 'Boom!' } ;
0 commit comments