Skip to content

Commit 128e278

Browse files
committed
Add Base
1 parent 3195e95 commit 128e278

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func Discover(addr string) ([]*openpgp.Entity, error) {
3333
}
3434
}
3535

36-
url := "https://" + domain + wellKnownBase + "/hu/" + hashLocal(local)
36+
url := "https://" + domain + Base + "/hu/" + hashLocal(local)
3737
resp, err := http.Get(url)
3838
if err != nil {
3939
return nil, err

server.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ func (h *Handler) serveDiscovery(w http.ResponseWriter, r *http.Request, hash st
3737

3838
// ServeHTTP implements http.Handler.
3939
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
40-
if !strings.HasPrefix(r.URL.Path, wellKnownBase) {
40+
if !strings.HasPrefix(r.URL.Path, Base) {
4141
http.NotFound(w, r)
4242
return
4343
}
44+
path := strings.TrimPrefix(r.URL.Path, Base)
4445

45-
path := strings.TrimPrefix(r.URL.Path, wellKnownBase)
4646
if path == "/policy" {
4747
h.servePolicy(w, r)
4848
return

wkd.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import (
1010
"github.com/tv42/zbase32"
1111
)
1212

13-
const wellKnownBase = "/.well-known/openpgpkey"
13+
// Base is the well-known base path for WKD.
14+
const Base = "/.well-known/openpgpkey"
1415

1516
// ErrNotFound is returned when the directory doesn't contain a public key for
1617
// the provided address.

0 commit comments

Comments
 (0)