diff options
-rw-r--r-- | gopherproxy/gopherproxy.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/gopherproxy/gopherproxy.go b/gopherproxy/gopherproxy.go index 4a7d972..453ee9c 100644 --- a/gopherproxy/gopherproxy.go +++ b/gopherproxy/gopherproxy.go | |||
@@ -29,6 +29,10 @@ import ( | |||
29 | "github.com/temoto/robotstxt" | 29 | "github.com/temoto/robotstxt" |
30 | ) | 30 | ) |
31 | 31 | ||
32 | var ( | ||
33 | TermEscapeSGRPattern = regexp.MustCompile("\\[\\d+(;\\d+)*m") | ||
34 | ) | ||
35 | |||
32 | const ( | 36 | const ( |
33 | ITEM_TYPE_GEMINI_LINE = "" | 37 | ITEM_TYPE_GEMINI_LINE = "" |
34 | ITEM_TYPE_GEMINI_LINK = " =>" | 38 | ITEM_TYPE_GEMINI_LINK = " =>" |
@@ -177,6 +181,7 @@ func parseGeminiDocument(body *bytes.Buffer, uri string, hostport string) (items | |||
177 | 181 | ||
178 | for scanner.Scan() { | 182 | for scanner.Scan() { |
179 | line := strings.Trim(scanner.Text(), "\r\n") | 183 | line := strings.Trim(scanner.Text(), "\r\n") |
184 | line = TermEscapeSGRPattern.ReplaceAllString(line, "") | ||
180 | 185 | ||
181 | item := Item{ | 186 | item := Item{ |
182 | Type: ITEM_TYPE_GEMINI_LINE, | 187 | Type: ITEM_TYPE_GEMINI_LINE, |