Skip to content

Download files to their original filename #1676

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 5, 2017

Conversation

silverwind
Copy link
Member

@silverwind silverwind commented May 4, 2017

This removes the path from download filenames, so dir/file.txt now downloads to file.txt instead of dir-file.txt (browsers replace slashes with dashes).

@lafriks
Copy link
Member

lafriks commented May 4, 2017

LGTM

@tboerger tboerger added the lgtm/need 1 This PR needs approval from one additional maintainer to be merged. label May 4, 2017
@sapk
Copy link
Member

sapk commented May 4, 2017

LGTM

@tboerger tboerger added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels May 4, 2017
@@ -27,6 +28,7 @@ func ServeData(ctx *context.Context, name string, reader io.Reader) error {

// Google Chrome dislike commas in filenames, so let's change it to a space
name = strings.Replace(name, ",", " ", -1)
name = path.Base(name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible for little optimization, maybe do path.Base() before String.replace()
It could even be done like name = strings.Replace(path.Base(name), ",", " ", -1)

@lunny lunny added the type/enhancement An improvement of existing functionality label May 5, 2017
@lunny lunny added this to the 1.2.0 milestone May 5, 2017
@silverwind silverwind force-pushed the download-filename branch from 54ba322 to 2ef6252 Compare May 5, 2017 01:14
@silverwind
Copy link
Member Author

@sapk updated, path.Base is applied before the Chrome workaround now. I didn't combine the lines because the path removal isn't part of the workaround.

@lunny lunny merged commit 935caa7 into go-gitea:master May 5, 2017
@silverwind silverwind deleted the download-filename branch May 5, 2017 07:24
@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants