Browse Source

Properly remove all the whitespace

vuex
Schneider 7 years ago
parent
commit
16f65b97e4
  1. 3
      .gitignore
  2. 6
      server/server.go

3
.gitignore

@ -6,3 +6,6 @@ yarn-debug.log*
yarn-error.log* yarn-error.log*
static/*mensa*.json static/*mensa*.json
static/*bistro*.json static/*bistro*.json
server/*.json
server/server
.*.swp

6
server/server.go

@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"os" "os"
"regexp"
"strings" "strings"
"github.com/PuerkitoBio/goquery" "github.com/PuerkitoBio/goquery"
@ -34,6 +35,7 @@ var (
"Mensa+Italia": "mensaitalia", "Mensa+Italia": "mensaitalia",
"Bistro+HAWK": "bistrohawk", "Bistro+HAWK": "bistrohawk",
} }
trimRegex = regexp.MustCompile(`\s{2,}`)
) )
func main() { func main() {
@ -93,9 +95,7 @@ func parseDate(doc *goquery.Document) string {
} }
func strip(old string) string { func strip(old string) string {
new := strings.Replace(old, "\t", "", -1)
new = strings.Replace(new, "\n", "", -1)
return new
return strings.TrimSpace(trimRegex.ReplaceAllString(old, " "))
} }
func parseMeals(doc *goquery.Document) ([]Meal, error) { func parseMeals(doc *goquery.Document) ([]Meal, error) {

Loading…
Cancel
Save