diff --git a/interwiki/interwiki.go b/interwiki/interwiki.go index 519a5d6..6e2ef36 100644 --- a/interwiki/interwiki.go +++ b/interwiki/interwiki.go @@ -45,13 +45,27 @@ func addEntry(wiki *Wiki) error { defer mutex.Unlock() var ( - names = append(wiki.Aliases, wiki.Name) + // non-empty names only + names = func(names []string) []string { + var result []string + for _, name := range names { + if name != "" { + result = append(result, name) + } + } + return result + }(append(wiki.Aliases, wiki.Name)) ok, name = areNamesFree(names) ) if !ok { log.Printf("There are multiple uses of the same name ā€˜%sā€™\n", name) return errors.New(name) } + if len(names) == 0 { + log.Println("No names passed for a new interwiki entry") + // There is something clearly wrong with error-returning in this function. + return errors.New("") + } listOfEntries = append(listOfEntries, wiki) for _, name := range names {