Browse Source

Limiting the length of the request's path.

Nick Presta 12 years ago
parent
commit
7fc854b620
1 changed files with 9 additions and 2 deletions
  1. 9 2
      src/ngrok/client/views/term/http.go

+ 9 - 2
src/ngrok/client/views/term/http.go

@@ -6,10 +6,13 @@ import (
 	"ngrok/log"
 	"ngrok/proto"
 	"ngrok/util"
+	"strings"
+	"unicode/utf8"
 )
 
 const (
-	size = 10
+	size          = 10
+	pathMaxLength = 25
 )
 
 type HttpView struct {
@@ -69,7 +72,11 @@ func (v *HttpView) Render() {
 	v.Printf(0, 1, "-------------")
 	for i, obj := range v.HttpRequests.Slice() {
 		txn := obj.(*proto.HttpTxn)
-		v.Printf(0, 3+i, "%s %v", txn.Req.Method, txn.Req.URL.Path)
+		path := txn.Req.URL.Path
+		if utf8.RuneCountInString(path) > pathMaxLength {
+			path = strings.Join(strings.SplitAfterN(path, "", pathMaxLength+1)[:pathMaxLength], "")
+		}
+		v.Printf(0, 3+i, "%s %v", txn.Req.Method, path)
 		if txn.Resp != nil {
 			v.APrintf(colorFor(txn.Resp.Status), 30, 3+i, "%s", txn.Resp.Status)
 		}