General web browser handler for bzz: protocol. Changes address bar.

This commit is contained in:
Daniel A. Nagy 2015-05-12 16:44:45 +02:00
parent 1ab5ec387a
commit 4e32d8c392
2 changed files with 17 additions and 1 deletions

15
bzz/bzzup/bzzhandler.html Normal file
View file

@ -0,0 +1,15 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
<title>Register Swarm protocol handler</title>
<script type="text/javascript">
navigator.registerProtocolHandler("bzz",
"http://localhost:8500/%s",
"Swarm handler");
</script>
</head>
<body>
<h1>Register Swarm protocol handler</h1>
<p>This web page will install a web protocol handler for the <code>bzz:</code> protocol.</p>
</body>
</html>

View file

@ -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" {