Skip to content
This repository has been archived by the owner on Dec 20, 2018. It is now read-only.

Commit

Permalink
Escape spaces and hyphens when generating cli filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
jbowes committed Aug 11, 2013
1 parent a34e872 commit 8e6e740
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (

var (
wsReplacer = strings.NewReplacer("__", "_", "_", " ")
revWsReplacer = strings.NewReplacer(" ", "_", "_", "__", "-", "--")

// set last modifed to server startup. close enough to release.
lastModified = time.Now()
Expand Down Expand Up @@ -137,8 +138,8 @@ func cliMode(vendor string, status string, color string, args []string) {
}
d := Data{vendor, status, c}

// XXX could escape here
name := vendor + "-" + status + "-" + color + ".png"
name := fmt.Sprintf("%s-%s-%s.png", revWsReplacer.Replace(vendor),
revWsReplacer.Replace(status), color);

if len(args) > 1 {
fatal("You can only specify one output file name")
Expand Down

0 comments on commit 8e6e740

Please sign in to comment.