diff --git a/src/cdn/downloadWithCurl.ts b/src/cdn/downloadWithCurl.ts index 6e8ed4d..ffa9dee 100644 --- a/src/cdn/downloadWithCurl.ts +++ b/src/cdn/downloadWithCurl.ts @@ -13,7 +13,7 @@ const CHECK_INTERVAL = 15; */ export default function downloadWithCurl({ host, path, tempFileName }: {host: string, path: string, tempFileName: string}): Promise { return new Promise(function(resolve, reject) { - const url = `http://${host}${(path.substr(0, 1) === '/' ? '' : '/')}${path}`; + const url = `http://${host}${(path[0] === '/' ? '' : '/')}${path}`; const parameters: string[] = [ //... @@ -36,7 +36,7 @@ export default function downloadWithCurl({ host, path, tempFileName }: {host: st if (code === 0) { resolve(tempFileName); } else if (code === 28) { - reject(`Download speed too slow, will restart "${url}".`); + reject(`Download speed too slow, restarting "${path.includes('/') ? path.substr(path.lastIndexOf('/')) : path}".`); } else { reject(`Error in process:\n> curl ${parameters.join(' ')}\nNon-zero exit code ${code}.`); }