From 93a35ad2516accdcb9735db509550979d01de2c3 Mon Sep 17 00:00:00 2001 From: Ramires Viana <59319979+ramiresviana@users.noreply.github.com> Date: Wed, 17 Mar 2021 17:54:25 +0000 Subject: [PATCH 1/4] fix: prefix handling on http router --- http/data.go | 2 +- http/utils.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) 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) }) } From eeadc532fe6057969b3c1a4726f236851b154cfa Mon Sep 17 00:00:00 2001 From: Ramires Viana <59319979+ramiresviana@users.noreply.github.com> Date: Wed, 17 Mar 2021 18:06:56 +0000 Subject: [PATCH 2/4] fix: text file detection on editor --- files/file.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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 { From 22f4be8f54162b7cf494177705ffb8b09117bd01 Mon Sep 17 00:00:00 2001 From: Ramires Viana <59319979+ramiresviana@users.noreply.github.com> Date: Thu, 18 Mar 2021 13:10:10 +0000 Subject: [PATCH 3/4] fix: qr code url on share --- frontend/src/views/Share.vue | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 From 5f4a0317ab5685fe4a558df74e604c12e04a1c10 Mon Sep 17 00:00:00 2001 From: Ramires Viana <59319979+ramiresviana@users.noreply.github.com> Date: Thu, 18 Mar 2021 18:24:24 +0000 Subject: [PATCH 4/4] fix: hide dotfile error on share --- rules/rules.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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.