File tree Expand file tree Collapse file tree 3 files changed +1
-21
lines changed Expand file tree Collapse file tree 3 files changed +1
-21
lines changed Original file line number Diff line number Diff line change 11import  { imageInfo }  from  '../../utils/image.ts' ; 
2- import  { isUrl }  from  '../../utils/url.ts' ; 
32import  { textareaInsertText ,  triggerEditorContentChanged }  from  './EditorMarkdown.ts' ; 
43import  { 
54  DropzoneCustomEventRemovedFile , 
Original file line number Diff line number Diff line change 1- import  { pathEscapeSegments ,  isUrl ,   toOriginUrl }  from  './url.ts' ; 
1+ import  { pathEscapeSegments ,  toOriginUrl }  from  './url.ts' ; 
22
33test ( 'pathEscapeSegments' ,  ( )  =>  { 
44  expect ( pathEscapeSegments ( 'a/b/c' ) ) . toEqual ( 'a/b/c' ) ; 
55  expect ( pathEscapeSegments ( 'a/b/ c' ) ) . toEqual ( 'a/b/%20c' ) ; 
66} ) ; 
77
8- test ( 'isUrl' ,  ( )  =>  { 
9-   expect ( isUrl ( 'https://example.com' ) ) . toEqual ( true ) ; 
10-   expect ( isUrl ( 'https://example.com/' ) ) . toEqual ( true ) ; 
11-   expect ( isUrl ( 'https://example.com/index.html' ) ) . toEqual ( true ) ; 
12-   expect ( isUrl ( '/index.html' ) ) . toEqual ( false ) ; 
13- } ) ; 
14- 
158test ( 'toOriginUrl' ,  ( )  =>  { 
169  const  oldLocation  =  String ( window . location ) ; 
1710  for  ( const  origin  of  [ 'https://example.com' ,  'https://example.com:3000' ] )  { 
Original file line number Diff line number Diff line change @@ -2,18 +2,6 @@ export function pathEscapeSegments(s: string): string {
22  return  s . split ( '/' ) . map ( encodeURIComponent ) . join ( '/' ) ; 
33} 
44
5- function  stripSlash ( url : string ) : string  { 
6-   return  url . endsWith ( '/' )  ? url . slice ( 0 ,  - 1 )  : url ; 
7- } 
8- 
9- export  function  isUrl ( url : string ) : boolean  { 
10-   try  { 
11-     return  stripSlash ( ( new  URL ( url ) . href ) ) . trim ( )  ===  stripSlash ( url ) . trim ( ) ; 
12-   }  catch  { 
13-     return  false ; 
14-   } 
15- } 
16- 
175/** Convert an absolute or relative URL to an absolute URL with the current origin. It only 
186 *  processes absolute HTTP/HTTPS URLs or relative URLs like '/xxx' or '//host/xxx'. */ 
197export  function  toOriginUrl ( urlStr : string )  { 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments