@@ -10,7 +10,7 @@ export async function fetchFiles(url, content = false) {
1010 const result = extractSourceFromPath ( url )
1111 const apiPath = getApiPath ( 'api/resources' , {
1212 path : encodeURIComponent ( result . path ) ,
13- source : result . source ,
13+ source : encodeURIComponent ( result . source ) ,
1414 ...( content && { content : 'true' } )
1515 } )
1616 const res = await fetchURL ( apiPath )
@@ -26,7 +26,7 @@ export async function fetchFiles(url, content = false) {
2626async function resourceAction ( url , method , content ) {
2727 try {
2828 const result = extractSourceFromPath ( url )
29- let source = result . source
29+ let source = encodeURIComponent ( result . source )
3030 let path = result . path
3131 let opts = { method }
3232 if ( content ) {
@@ -69,14 +69,13 @@ export function download(format, files) {
6969 if ( format !== 'zip' ) {
7070 format = 'tar.gz'
7171 }
72-
7372 let fileargs = ''
7473 if ( files . length === 1 ) {
75- const result = extractSourceFromPath ( decodeURI ( files [ 0 ] ) )
74+ const result = extractSourceFromPath ( decodeURIComponent ( files [ 0 ] ) )
7675 fileargs = result . source + '::' + result . path + '||'
7776 } else {
7877 for ( let file of files ) {
79- const result = extractSourceFromPath ( decodeURI ( file ) )
78+ const result = extractSourceFromPath ( decodeURIComponent ( file ) )
8079 fileargs += result . source + '::' + result . path + '||'
8180 }
8281 }
@@ -110,7 +109,7 @@ export async function post(url, content = '', overwrite = false, onupload) {
110109
111110 const apiPath = getApiPath ( 'api/resources' , {
112111 path : result . path ,
113- source : result . source ,
112+ source : encodeURIComponent ( result . source ) ,
114113 override : overwrite
115114 } )
116115 return new Promise ( ( resolve , reject ) => {
@@ -164,7 +163,7 @@ export async function moveCopy(
164163 const toResult = extractSourceFromPath ( item . to )
165164 let localParams = {
166165 ...params ,
167- destination : toResult . source + '::' + toResult . path ,
166+ destination : encodeURIComponent ( toResult . source ) + '::' + toResult . path ,
168167 from : fromResult . source + '::' + fromResult . path
169168 }
170169 const apiPath = getApiPath ( 'api/resources' , localParams )
@@ -189,12 +188,11 @@ export async function moveCopy(
189188 }
190189}
191190
192- export async function checksum ( url , algo ) {
191+ export async function checksum ( source , path , algo ) {
193192 try {
194- const result = extractSourceFromPath ( url )
195193 const params = {
196- path : encodeURIComponent ( result . path ) ,
197- source : result . source ,
194+ path : encodeURIComponent ( path ) ,
195+ source : encodeURIComponent ( source ) ,
198196 checksum : algo
199197 }
200198 const apiPath = getApiPath ( 'api/resources' , params )
@@ -210,7 +208,7 @@ export async function checksum(url, algo) {
210208export function getDownloadURL ( source , path , inline , useExternal ) {
211209 try {
212210 const params = {
213- files : source + '::' + encodeURIComponent ( path ) ,
211+ files : encodeURIComponent ( source ) + '::' + encodeURIComponent ( path ) ,
214212 ...( inline && { inline : 'true' } )
215213 }
216214 const apiPath = getApiPath ( 'api/raw' , params )
@@ -230,7 +228,7 @@ export function getPreviewURL(source, path, modified) {
230228 const params = {
231229 path : encodeURIComponent ( path ) ,
232230 key : Date . parse ( modified ) , // Use modified date as cache key
233- source : source ,
231+ source : encodeURIComponent ( source ) ,
234232 inline : 'true'
235233 }
236234 const apiPath = getApiPath ( 'api/preview' , params )
0 commit comments