From ee1536160e0d5a68afc3a8c0e9dc25bd170c7bd9 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Sat, 21 Jan 2017 21:10:01 +0000 Subject: [PATCH] fix file info URL and webdav move destination URL --- _embed/public/js/common.js | 7 +++++-- _embed/public/js/listing.js | 2 +- _embed/templates/base.tmpl | 3 ++- file/info.go | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/_embed/public/js/common.js b/_embed/public/js/common.js index d4e1a56f..1be8dd87 100644 --- a/_embed/public/js/common.js +++ b/_embed/public/js/common.js @@ -137,10 +137,13 @@ webdav.convertURL = function (url) { webdav.move = function (oldLink, newLink) { return new Promise((resolve, reject) => { - let request = new XMLHttpRequest(); + let request = new XMLHttpRequest(), + destination = newLink.replace(baseURL + "/", webdavURL + "/"); + + destination = window.location.origin + destination.substring(prefixURL.length); request.open('MOVE', webdav.convertURL(oldLink), true); - request.setRequestHeader('Destination', webdav.convertURL(newLink)); + request.setRequestHeader('Destination', destination); request.onload = () => { if(request.status == 201 || request.status == 204) { resolve(); diff --git a/_embed/public/js/listing.js b/_embed/public/js/listing.js index 39e25e42..28f3a289 100644 --- a/_embed/public/js/listing.js +++ b/_embed/public/js/listing.js @@ -562,4 +562,4 @@ document.addEventListener('DOMContentLoaded', event => { document.addEventListener("drop", listing.documentDrop, false); } -}); \ No newline at end of file +}); diff --git a/_embed/templates/base.tmpl b/_embed/templates/base.tmpl index 9e357acf..bdd7d4a0 100644 --- a/_embed/templates/base.tmpl +++ b/_embed/templates/base.tmpl @@ -16,7 +16,8 @@ {{- if .IsDir }} diff --git a/file/info.go b/file/info.go index c1da9b29..5b059b83 100644 --- a/file/info.go +++ b/file/info.go @@ -36,7 +36,7 @@ type Info struct { func GetInfo(url *url.URL, c *config.Config, u *config.User) (*Info, int, error) { var err error - i := &Info{URL: url.Path} + i := &Info{URL: c.PrefixURL + url.Path} i.VirtualPath = strings.Replace(url.Path, c.BaseURL, "", 1) i.VirtualPath = strings.TrimPrefix(i.VirtualPath, "/") i.VirtualPath = "/" + i.VirtualPath