Skip to content
This repository has been archived by the owner on Nov 18, 2024. It is now read-only.

Commit

Permalink
fixes target of encoded filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Winkler committed Nov 11, 2016
1 parent 6c92b3a commit 41e36bc
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io/ioutil"
"mime"
"net/http"
"net/url"
"os"
"path"
"path/filepath"
Expand Down Expand Up @@ -37,7 +38,7 @@ var (
)

const (
VERSION string = "1.9.1"
VERSION string = "1.9.2"
RELEASE_URL string = "https://github.com/Seklfreak/discord-image-downloader-go/releases/latest"
IMGUR_CLIENT_ID string = "a39473314df3f59"
)
Expand Down Expand Up @@ -411,9 +412,14 @@ func downloadFromUrl(dUrl string, filename string, path string) {
for key, iHeader := range response.Header {
if key == "Content-Disposition" {
_, params, err := mime.ParseMediaType(iHeader[0])
newFilename := params["filename"]
if err == nil && newFilename != "" {
filename = newFilename
if err == nil {
newFilename, err := url.QueryUnescape(params["filename"])
if err != nil {
newFilename = params["filename"]
}
if newFilename != "" {
filename = newFilename
}
}
}
}
Expand Down

0 comments on commit 41e36bc

Please sign in to comment.