mirror of
				https://github.com/osmarks/mycorrhiza.git
				synced 2025-10-31 15:43:00 +00:00 
			
		
		
		
	Interwiki: Fix the bug that occurred with entries with no aliases
This commit is contained in:
		| @@ -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 { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Timur Ismagilov
					Timur Ismagilov