Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit 395d5bc

Browse files
committed
fix #140
1 parent f4acdee commit 395d5bc

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Diff for: src/util/url-add.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ module.exports = (send) => {
3535
const validUrl = (url) => typeof url === 'string' && url.startsWith('http')
3636

3737
const requestWithRedirect = (url, opts, sendOneFile, callback) => {
38-
const req = request(parseUrl(url).protocol)(url, (res) => {
38+
const parsedUrl = parseUrl(url)
39+
40+
const req = request(parsedUrl.protocol)(url, (res) => {
3941
if (res.statusCode >= 400) {
4042
return callback(new Error(`Failed to download with ${res.statusCode}`))
4143
}
@@ -46,13 +48,18 @@ const requestWithRedirect = (url, opts, sendOneFile, callback) => {
4648
if (!validUrl(redirection)) {
4749
return callback(new Error('redirection url must be an http(s) url'))
4850
}
51+
4952
requestWithRedirect(redirection, opts, sendOneFile, callback)
5053
} else {
5154
const requestOpts = {
5255
qs: opts,
5356
converter: FileResultStreamConverter
5457
}
55-
sendOneFile(res, requestOpts, callback)
58+
59+
sendOneFile({
60+
content: res,
61+
path: parsedUrl.pathname.split('/').pop()
62+
}, requestOpts, callback)
5663
}
5764
})
5865

0 commit comments

Comments
 (0)