File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -106,11 +106,17 @@ async function newStorageDir(path) {
106106 }
107107 async function search ( filePath , format = STOF_TEXT ) {
108108 var fpath = `${ storageO } /${ filePath } ` ;
109+ const doubleSlash = '//' ;
110+ const doubleSlashIndexLast = fpath . lastIndexOf ( doubleSlash ) ;
111+ const doubleSlashIndex = fpath . indexOf ( doubleSlash ) ;
109112
110- if ( fpath . startsWith ( 'http' ) || fpath . startsWith ( 'ftp' ) )
111- fpath = fpath . replace ( '//' , '/' ) ;
112- else
113- fpath = fpath . replace ( '//' , '/_base/' ) ;
113+ if ( doubleSlashIndexLast != doubleSlashIndex && doubleSlashIndex >= 0 && doubleSlashIndexLast >= 0 ) {
114+ var replacement = '/_base/' ;
115+ if ( fpath . startsWith ( 'http' ) || fpath . startsWith ( 'ftp' ) )
116+ replacement = '/' ;
117+
118+ fpath = fpath . slice ( 0 , doubleSlashIndexLast ) + replacement + fpath . slice ( doubleSlashIndexLast + 2 ) ;
119+ }
114120
115121 const response = await fetchDataOrEmpty ( fpath ) ;
116122
You can’t perform that action at this time.
0 commit comments