about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEmile <hanemile@protonmail.com>2020-03-22 15:51:20 +0100
committerEmile <hanemile@protonmail.com>2020-03-22 15:51:20 +0100
commit0e300e586d46fa8a32856bfe6e519828f8c17fba (patch)
treea49f7678aaa068498262607124fa55bfb7d4706d
parentd532f73360bf4a7c347cd9a3a7427f6551496c4f (diff)
defined the view query catcher
-rw-r--r--src/http/http.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/http/http.go b/src/http/http.go
index 5593969..ee5434e 100644
--- a/src/http/http.go
+++ b/src/http/http.go
@@ -147,6 +147,22 @@ func pathHandler(w http.ResponseWriter, r *http.Request) {
 		return
 	}
 
+	// if the ?view query is present, retirect to the view handler with the
+	// needed information
+	if query["view"] != nil {
+
+		// strip the file before and after the request
+		strippedFile := strings.Replace(r.URL.Path, root, "", -1)
+
+		// base64 encode the file path
+		strippedFileBase64 := base64.StdEncoding.EncodeToString([]byte(strippedFile))
+
+		path := fmt.Sprintf("/view?file=%s&hash=%s", strippedFileBase64, query["hash"][0])
+		http.Redirect(w, r, path, http.StatusSeeOther)
+		return
+	}
+
+	// define the breadcrumbs
 	breadcrumbsList := breadcrumbs(r)
 	content["Breadcrumbs"] = breadcrumbsList