Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

Add redirection for plugin urls

Chaitanya Bankanhalcf68e61f40cb
diff --git a/fs/rc/rcserver/rcserver.go b/fs/rc/rcserver/rcserver.go
index 6dd030ad0..622e08597 100644
--- a/fs/rc/rcserver/rcserver.go
+++ b/fs/rc/rcserver/rcserver.go
@@ -368,11 +368,11 @@ func (s *Server) serveRemote(w http.ResponseWriter, r *http.Request, path string
// Match URLS of the form [fs]/remote
var fsMatch = regexp.MustCompile(`^\[(.*?)\](.*)$`)
+var referrerPathReg = regexp.MustCompile("^(https?)://(.+):([0-9]+)?/(.*)$")
func (s *Server) handleGet(w http.ResponseWriter, r *http.Request, path string) {
// Look to see if this has an fs in the path
fsMatchResult := fsMatch.FindStringSubmatch(path)
- pluginsMatchResult := webgui.PluginsMatch.FindStringSubmatch(path)
switch {
case fsMatchResult != nil && s.opt.Serve:
@@ -387,6 +387,8 @@ func (s *Server) handleGet(w http.ResponseWriter, r *http.Request, path string)
s.serveRoot(w, r)
return
case s.files != nil:
+ pluginsMatchResult := webgui.PluginsMatch.FindStringSubmatch(path)
+
if s.opt.WebUI && pluginsMatchResult != nil {
ok := webgui.ServePluginOK(w, r, pluginsMatchResult)
if !ok {
@@ -395,6 +397,20 @@ func (s *Server) handleGet(w http.ResponseWriter, r *http.Request, path string)
return
}
return
+ } else if s.opt.WebUI {
+ referrer := r.Referer()
+ referrerPathMatch := referrerPathReg.FindStringSubmatch(referrer)
+
+ if referrerPathMatch != nil {
+ referrerPluginMatch := webgui.PluginsMatch.FindStringSubmatch(referrerPathMatch[4])
+ if referrerPluginMatch != nil {
+ path = fmt.Sprintf("/plugins/%s/%s/%s", referrerPluginMatch[1], referrerPluginMatch[2], path)
+
+ http.Redirect(w, r, path, http.StatusMovedPermanently)
+ //s.pluginsHandler.ServeHTTP(w, r)
+ return
+ }
+ }
}
// Serve the files
r.URL.Path = "/" + path