diff --git a/files/file.go b/files/file.go index 9e1eb19d..c1451878 100644 --- a/files/file.go +++ b/files/file.go @@ -148,12 +148,15 @@ func (i *FileInfo) detectType(modify, saveContent, readHeader bool) error { // of files couldn't be opened: we'd have immediately // a 500 even though it doesn't matter. So we just log it. - var buffer []byte - mimetype := mime.TypeByExtension(i.Extension) - if mimetype == "" && readHeader { + + var buffer []byte + if readHeader { buffer = i.readFirstBytes() - mimetype = http.DetectContentType(buffer) + + if mimetype == "" { + mimetype = http.DetectContentType(buffer) + } } switch { diff --git a/frontend/src/views/Share.vue b/frontend/src/views/Share.vue index 383f494e..c5a463d8 100644 --- a/frontend/src/views/Share.vue +++ b/frontend/src/views/Share.vue @@ -31,7 +31,7 @@ {{ $t('buttons.download') }}
- +
@@ -161,6 +161,9 @@ export default { const path = this.$route.path.split('/').splice(2).join('/') return `${baseURL}/api/public/dl/${path}${queryArg}` }, + fullLink: function () { + return window.location.origin + this.link + }, humanSize: function () { if (this.req.isDir) { return this.req.items.length diff --git a/http/data.go b/http/data.go index bc9bdd56..9779cb43 100644 --- a/http/data.go +++ b/http/data.go @@ -73,5 +73,5 @@ func handle(fn handleFunc, prefix string, store *storage.Storage, server *settin } }) - return http.StripPrefix(prefix, handler) + return stripPrefix(prefix, handler) } diff --git a/http/utils.go b/http/utils.go index ce605b36..c1c3fa65 100644 --- a/http/utils.go +++ b/http/utils.go @@ -56,11 +56,13 @@ func stripPrefix(prefix string, h http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { p := strings.TrimPrefix(r.URL.Path, prefix) + rp := strings.TrimPrefix(r.URL.RawPath, prefix) r2 := new(http.Request) *r2 = *r r2.URL = new(url.URL) *r2.URL = *r.URL r2.URL.Path = p + r2.URL.RawPath = rp h.ServeHTTP(w, r2) }) } diff --git a/rules/rules.go b/rules/rules.go index d8a7f967..7c6ef11b 100644 --- a/rules/rules.go +++ b/rules/rules.go @@ -22,7 +22,7 @@ type Rule struct { // MatchHidden matches paths with a basename // that begins with a dot. func MatchHidden(path string) bool { - return strings.HasPrefix(filepath.Base(path), ".") + return path != "" && strings.HasPrefix(filepath.Base(path), ".") } // Matches matches a path against a rule.