commit
d2e6d23741
|
@ -148,13 +148,16 @@ func (i *FileInfo) detectType(modify, saveContent, readHeader bool) error {
|
||||||
// of files couldn't be opened: we'd have immediately
|
// of files couldn't be opened: we'd have immediately
|
||||||
// a 500 even though it doesn't matter. So we just log it.
|
// a 500 even though it doesn't matter. So we just log it.
|
||||||
|
|
||||||
var buffer []byte
|
|
||||||
|
|
||||||
mimetype := mime.TypeByExtension(i.Extension)
|
mimetype := mime.TypeByExtension(i.Extension)
|
||||||
if mimetype == "" && readHeader {
|
|
||||||
|
var buffer []byte
|
||||||
|
if readHeader {
|
||||||
buffer = i.readFirstBytes()
|
buffer = i.readFirstBytes()
|
||||||
|
|
||||||
|
if mimetype == "" {
|
||||||
mimetype = http.DetectContentType(buffer)
|
mimetype = http.DetectContentType(buffer)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case strings.HasPrefix(mimetype, "video"):
|
case strings.HasPrefix(mimetype, "video"):
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
<a target="_blank" :href="link" class="button button--flat">{{ $t('buttons.download') }}</a>
|
<a target="_blank" :href="link" class="button button--flat">{{ $t('buttons.download') }}</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="share__box__element share__box__center">
|
<div class="share__box__element share__box__center">
|
||||||
<qrcode-vue :value="link" size="200" level="M"></qrcode-vue>
|
<qrcode-vue :value="fullLink" size="200" level="M"></qrcode-vue>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="req.isDir && req.items.length > 0" class="share__box share__box__items">
|
<div v-if="req.isDir && req.items.length > 0" class="share__box share__box__items">
|
||||||
|
@ -161,6 +161,9 @@ export default {
|
||||||
const path = this.$route.path.split('/').splice(2).join('/')
|
const path = this.$route.path.split('/').splice(2).join('/')
|
||||||
return `${baseURL}/api/public/dl/${path}${queryArg}`
|
return `${baseURL}/api/public/dl/${path}${queryArg}`
|
||||||
},
|
},
|
||||||
|
fullLink: function () {
|
||||||
|
return window.location.origin + this.link
|
||||||
|
},
|
||||||
humanSize: function () {
|
humanSize: function () {
|
||||||
if (this.req.isDir) {
|
if (this.req.isDir) {
|
||||||
return this.req.items.length
|
return this.req.items.length
|
||||||
|
|
|
@ -73,5 +73,5 @@ func handle(fn handleFunc, prefix string, store *storage.Storage, server *settin
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
return http.StripPrefix(prefix, handler)
|
return stripPrefix(prefix, handler)
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,11 +56,13 @@ func stripPrefix(prefix string, h http.Handler) http.Handler {
|
||||||
|
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
p := strings.TrimPrefix(r.URL.Path, prefix)
|
p := strings.TrimPrefix(r.URL.Path, prefix)
|
||||||
|
rp := strings.TrimPrefix(r.URL.RawPath, prefix)
|
||||||
r2 := new(http.Request)
|
r2 := new(http.Request)
|
||||||
*r2 = *r
|
*r2 = *r
|
||||||
r2.URL = new(url.URL)
|
r2.URL = new(url.URL)
|
||||||
*r2.URL = *r.URL
|
*r2.URL = *r.URL
|
||||||
r2.URL.Path = p
|
r2.URL.Path = p
|
||||||
|
r2.URL.RawPath = rp
|
||||||
h.ServeHTTP(w, r2)
|
h.ServeHTTP(w, r2)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ type Rule struct {
|
||||||
// MatchHidden matches paths with a basename
|
// MatchHidden matches paths with a basename
|
||||||
// that begins with a dot.
|
// that begins with a dot.
|
||||||
func MatchHidden(path string) bool {
|
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.
|
// Matches matches a path against a rule.
|
||||||
|
|
Loading…
Reference in New Issue