File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -531,6 +531,31 @@ describe('getJsxElementFromComponent', () => {
531531} ) ;
532532
533533describe ( 'validateTextLinks' , ( ) => {
534+ it ( 'handles custom protocols' , ( ) => {
535+ const allowedProtocols = [ 'http:' , 'file:' ] ;
536+ expect ( ( ) =>
537+ validateTextLinks (
538+ '[test](http://foo.bar)' ,
539+ ( ) => false ,
540+ allowedProtocols ,
541+ ) ,
542+ ) . not . toThrow ( ) ;
543+ expect ( ( ) =>
544+ validateTextLinks (
545+ '[test](https://foo.bar)' ,
546+ ( ) => false ,
547+ allowedProtocols ,
548+ ) ,
549+ ) . toThrow ( 'Invalid URL: Protocol must be one of: http:, file:.' ) ;
550+ expect ( ( ) =>
551+ validateTextLinks (
552+ '<file:///var/www/index.html>' ,
553+ ( ) => false ,
554+ allowedProtocols ,
555+ ) ,
556+ ) . not . toThrow ( ) ;
557+ } ) ;
558+
534559 it ( 'passes for valid links' , ( ) => {
535560 expect ( ( ) =>
536561 validateTextLinks ( '[test](https://foo.bar)' , ( ) => false ) ,
You can’t perform that action at this time.
0 commit comments