From 4e32d8c392144580a5a35820e4c067a37274e6fa Mon Sep 17 00:00:00 2001 From: "Daniel A. Nagy" Date: Tue, 12 May 2015 16:44:45 +0200 Subject: [PATCH] General web browser handler for bzz: protocol. Changes address bar. --- bzz/bzzup/bzzhandler.html | 15 +++++++++++++++ bzz/httpaccess.go | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 bzz/bzzup/bzzhandler.html diff --git a/bzz/bzzup/bzzhandler.html b/bzz/bzzup/bzzhandler.html new file mode 100644 index 0000000000..0d7a8b01a4 --- /dev/null +++ b/bzz/bzzup/bzzhandler.html @@ -0,0 +1,15 @@ + + + + Register Swarm protocol handler + + + +

Register Swarm protocol handler

+

This web page will install a web protocol handler for the bzz: protocol.

+ + diff --git a/bzz/httpaccess.go b/bzz/httpaccess.go index bfa85887e6..839b534ae6 100644 --- a/bzz/httpaccess.go +++ b/bzz/httpaccess.go @@ -20,6 +20,7 @@ const ( ) var ( + protocolMatcher = regexp.MustCompile("^/bzz:") uriMatcher = regexp.MustCompile("^/raw/[0-9A-Fa-f]{64}(?:/[a-z]+/[-+0-9a-z]+)?$") manifestMatcher = regexp.MustCompile("^/[0-9A-Fa-f]{64}") hashMatcher = regexp.MustCompile("^[0-9A-Fa-f]{64}$") @@ -94,7 +95,7 @@ func (self *sequentialReader) ReadAt(target []byte, off int64) (n int, err error } func handler(w http.ResponseWriter, r *http.Request, dpa *DPA) { - uri := r.RequestURI + uri := protocolMatcher.ReplaceAllString(r.RequestURI, "") switch { case r.Method == "POST": if uri == "/raw" {