File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed 
packages/common/src/utils Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import {
1010  filterReadOnlyPropertiesInJsonSchema  as  _filterReadOnlyPropertiesInJsonSchema , 
1111  filterWritablePropertiesInJsonSchema  as  _filterWritablePropertiesInJsonSchema , 
1212}  from  "./json_schema" ; 
13- import  {  isFilledString  as  _isFilledString ,  rtrim  as  _rtrim  }  from  "./string" ; 
13+ import  {  isFilledString  as  _isFilledString ,  isValidHttpUrl   as   _isValidHttpUrl ,   rtrim  as  _rtrim  }  from  "./string" ; 
1414
1515namespace  Utils  { 
1616  export  const  buildNestedSiteMap  =  _buildNestedSiteMap ; 
@@ -20,6 +20,7 @@ namespace Utils {
2020  export  const  isFormValid  =  _isFormValid ; 
2121  export  const  getFormValue  =  _getFormValue ; 
2222  export  const  isFilledString  =  _isFilledString ; 
23+   export  const  isValidHttpUrl  =  _isValidHttpUrl ; 
2324  export  const  rtrim  =  _rtrim ; 
2425  export  const  filterWritablePropertiesInJsonSchema  =  _filterWritablePropertiesInJsonSchema ; 
2526  export  const  filterReadOnlyPropertiesInJsonSchema  =  _filterReadOnlyPropertiesInJsonSchema ; 
Original file line number Diff line number Diff line change @@ -2,5 +2,15 @@ import * as R from "remeda";
22
33export  const  isFilledString  =  ( obj : unknown ) : obj  is string  =>  R . isString ( obj )  &&  ! R . isEmpty ( obj ) ; 
44
5+ export  const  isValidHttpUrl  =  ( obj : unknown ) : obj  is string  =>  { 
6+   try  { 
7+     const  url  =  new  URL ( obj  as  string ) ; 
8+     return  url . protocol  ===  "http:"  ||  url . protocol  ===  "https:" ; 
9+     // eslint-disable-next-line @typescript-eslint/no-unused-vars 
10+   }  catch  ( _ )  { 
11+     return  false ; 
12+   } 
13+ } ; 
14+ 
515// Remove whitespace from the right side of the input string. 
616export  const  rtrim  =  ( x : string ) : string  =>  x . replace ( / \s + $ / gm,  "" ) ; 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments