@@ -508,38 +508,50 @@ 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-
511+ describe ( 'isLnUri()' , ( ) => {
517512 it ( 'should accept lightning uri' , ( ) => {
518513 const uri =
519514 'lightning:lntb1500n1pdn2e0app5wlyxzspccpfvqmrtfr8p487xcch4hxtu2u0qzcke6mzpv222w8usdpa2fjkzep6ypxx2ap8wvs8qmrp0ysxzgrvd9nksarwd9hxwgrwv468wmmjdvsxwcqzysmr9jxv06zx53cyqa0sqntehy5tyrqu064xvw00qjep5f9gw57qcqp6qnpqyuprh90aqzfyf9ypq8uth7qte5ecjq0fng3y47mywwkfqq3megny' ;
520- expect ( helpers . isValidUri ( uri ) , 'to be' , true ) ;
515+ expect ( helpers . isLnUri ( uri ) , 'to be' , true ) ;
516+ } ) ;
517+
518+ it ( 'should reject bitcoin uri' , ( ) => {
519+ const uri = 'bitcoin:rfu4i1Mo2NF7TQsN9bMVLFSojSzcyQCEH5' ;
520+ expect ( helpers . isLnUri ( uri ) , 'to be' , false ) ;
521521 } ) ;
522522
523523 it ( 'should reject bitcoin address' , ( ) => {
524524 const uri = 'rfu4i1Mo2NF7TQsN9bMVLFSojSzcyQCEH5' ;
525- expect ( helpers . isValidUri ( uri ) , 'to be' , false ) ;
525+ expect ( helpers . isLnUri ( uri ) , 'to be' , false ) ;
526526 } ) ;
527527
528528 it ( 'should reject lightning invoice' , ( ) => {
529529 const uri =
530530 'lntb1500n1pdn2e0app5wlyxzspccpfvqmrtfr8p487xcch4hxtu2u0qzcke6mzpv222w8usdpa2fjkzep6ypxx2ap8wvs8qmrp0ysxzgrvd9nksarwd9hxwgrwv468wmmjdvsxwcqzysmr9jxv06zx53cyqa0sqntehy5tyrqu064xvw00qjep5f9gw57qcqp6qnpqyuprh90aqzfyf9ypq8uth7qte5ecjq0fng3y47mywwkfqq3megny' ;
531- expect ( helpers . isValidUri ( uri ) , 'to be' , false ) ;
531+ expect ( helpers . isLnUri ( uri ) , 'to be' , false ) ;
532+ } ) ;
533+
534+ it ( 'should mitigate xss' , ( ) => {
535+ const uri =
536+ 'lightning:lntb1500n1<script>alert("XSS")</script>p487xcch4hxtu2u0qzcke6mzpv222w8usdpa2fjkzep6ypxx2ap8wvs8qmrp0ysxzgrvd9nksarwd9hxwgrwv468wmmjdvsxwcqzysmr9jxv06zx53cyqa0sqntehy5tyrqu064xvw00qjep5f9gw57qcqp6qnpqyuprh90aqzfyf9ypq8uth7qte5ecjq0fng3y47mywwkfqq3megny' ;
537+ expect ( helpers . isLnUri ( uri ) , 'to be' , false ) ;
538+ } ) ;
539+ } ) ;
540+
541+ describe ( 'isAddress()' , ( ) => {
542+ it ( 'should accept bitcoin uri' , ( ) => {
543+ const address = 'rfu4i1Mo2NF7TQsN9bMVLFSojSzcyQCEH5' ;
544+ expect ( helpers . isAddress ( address ) , 'to be' , true ) ;
532545 } ) ;
533546
534547 it ( 'should reject invalid bitcoin uri' , ( ) => {
535- const uri = 'bitcoin: /INVALID/rfu4i1Mo2NF7TQsN9bMVLFSojSzcyQCEH5 ' ;
536- expect ( helpers . isValidUri ( uri ) , 'to be' , false ) ;
548+ const address = '/INVALID/rfu4i1Mo2NF7TQsN9bMVLFSoj ' ;
549+ expect ( helpers . isAddress ( address ) , 'to be' , false ) ;
537550 } ) ;
538551
539552 it ( 'should mitigate xss' , ( ) => {
540- const uri =
541- 'bitcoin:rfu4i1Mo2NF7T<script>alert("XSS")</script>QsN9bMVLFSojSzcyQCEH5' ;
542- expect ( helpers . isValidUri ( uri ) , 'to be' , false ) ;
553+ const address = 'rfu<script>alert("XSS")</script>' ;
554+ expect ( helpers . isAddress ( address ) , 'to be' , false ) ;
543555 } ) ;
544556 } ) ;
545557
0 commit comments