Browse Source

Properly remove all the whitespace

vuex
Schneider 6 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*
static/*mensa*.json
static/*bistro*.json
server/*.json
server/server
.*.swp

6
server/server.go

@ -5,6 +5,7 @@ import (
"fmt"
"io/ioutil"
"os"
"regexp"
"strings"
"github.com/PuerkitoBio/goquery"
@ -34,6 +35,7 @@ var (
"Mensa+Italia": "mensaitalia",
"Bistro+HAWK": "bistrohawk",
}
trimRegex = regexp.MustCompile(`\s{2,}`)
)
func main() {
@ -93,9 +95,7 @@ func parseDate(doc *goquery.Document) 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) {

Loading…
Cancel
Save