Merge pull request #9 from Sirupsen/target-comments
Add handling of comments in targets.txt
This commit is contained in:
@@ -29,10 +29,10 @@ func readTargets(source io.Reader) (Targets, error) {
|
||||
lines := make([]string, 0)
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
if line = strings.TrimSpace(line); line == "" { // Empty line
|
||||
continue
|
||||
|
||||
if line = strings.TrimSpace(line); line != "" && line[0:2] != "//" { // A comment or blank line
|
||||
lines = append(lines, line)
|
||||
}
|
||||
lines = append(lines, line)
|
||||
}
|
||||
if err := scanner.Err(); err != nil {
|
||||
return Targets{}, err
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
func TestReadTargets(t *testing.T) {
|
||||
lines := bytes.NewBufferString("GET http://lolcathost:9999/\n\nHEAD http://lolcathost:9999/\n")
|
||||
lines := bytes.NewBufferString("GET http://lolcathost:9999/\n\n // HEAD http://lolcathost.com this is a comment \nHEAD http://lolcathost:9999/\n")
|
||||
targets, err := readTargets(lines)
|
||||
if err != nil {
|
||||
t.Fatalf("Couldn't parse valid source: %s", err)
|
||||
|
||||
Reference in New Issue
Block a user