From f1eab971b0fb8dce91850823b04b96b72e5d2456 Mon Sep 17 00:00:00 2001 From: Janne Mareike Koschinski <janne@kuschku.de> Date: Sat, 27 Apr 2019 00:39:22 +0200 Subject: [PATCH] Fixed suggestions parsing --- client.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/client.go b/client.go index 62c865d..308f776 100644 --- a/client.go +++ b/client.go @@ -2,7 +2,9 @@ package bahn import ( "fmt" + "io/ioutil" "net/http" + "strings" "time" "net/url" @@ -174,7 +176,15 @@ func (c *ApiClient) Suggestions(line string, date time.Time) ([]Suggestion, erro return suggestions, err } - if suggestions, err = SuggestionsFromReader(response.Body); err != nil { + var content []byte + if content, err = ioutil.ReadAll(response.Body); err != nil { + return suggestions, err + } + strippedContent := string(content) + strippedContent = strings.TrimPrefix(strippedContent, "TSLs.sls = ") + strippedContent = strings.TrimSuffix(strippedContent, ";") + + if suggestions, err = SuggestionsFromBytes([]byte(strippedContent)); err != nil { return suggestions, err } -- GitLab