diff --git a/src/services/curl.ts b/src/services/curl.ts index bdc941b..6f5f315 100644 --- a/src/services/curl.ts +++ b/src/services/curl.ts @@ -10,7 +10,7 @@ import { AssertionFailureError, FancyFile } from 'civkit'; import { ServiceBadAttemptError, TempFileManager } from '../shared'; import { createBrotliDecompress, createInflate, createGunzip } from 'zlib'; import { ZSTDDecompress } from 'simple-zstd'; -import _, { set } from 'lodash'; +import _ from 'lodash'; import { Readable } from 'stream'; import { AsyncLocalContext } from './async-context'; @@ -277,7 +277,7 @@ export class CurlControl extends AsyncService { if ([301, 302, 307, 308].includes(r.statusCode)) { const headers = r.headers[r.headers.length - 1]; - const location = headers.Location || headers.location; + const location: string | undefined = headers.Location || headers.location; const setCookieHeader = headers['Set-Cookie'] || headers['set-cookie']; if (setCookieHeader) { @@ -292,7 +292,7 @@ export class CurlControl extends AsyncService { throw new AssertionFailureError(`Failed to access ${urlToCrawl}: Bad redirection from ${nextHopUrl}`); } - nextHopUrl = new URL(location, nextHopUrl); + nextHopUrl = new URL(location || '', nextHopUrl); fakeHeaderInfos.push(...r.headers); leftRedirection -= 1; continue;