hswg: make AttrList return nil for missing attrs
And update copyright years.
This commit is contained in:
		
							
								
								
									
										2
									
								
								LICENSE
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								LICENSE
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
				
			|||||||
Copyright (c) 2018 - 2021, Přemysl Eric Janouch <p@janouch.name>
 | 
					Copyright (c) 2018 - 2022, Přemysl Eric Janouch <p@janouch.name>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Permission to use, copy, modify, and/or distribute this software for any
 | 
					Permission to use, copy, modify, and/or distribute this software for any
 | 
				
			||||||
purpose with or without fee is hereby granted.
 | 
					purpose with or without fee is hereby granted.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -49,6 +49,10 @@ func (m *Metadata) Attr(name string) string {
 | 
				
			|||||||
// AttrList is similar to Attr, but splits the result at commas,
 | 
					// AttrList is similar to Attr, but splits the result at commas,
 | 
				
			||||||
// and trims whitespace around array elements.
 | 
					// and trims whitespace around array elements.
 | 
				
			||||||
func (m *Metadata) AttrList(name string) []string {
 | 
					func (m *Metadata) AttrList(name string) []string {
 | 
				
			||||||
 | 
						if !m.Attributes.Has(name) {
 | 
				
			||||||
 | 
							return nil
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	res := strings.Split(m.Attr(name), ",")
 | 
						res := strings.Split(m.Attr(name), ",")
 | 
				
			||||||
	for i := range res {
 | 
						for i := range res {
 | 
				
			||||||
		res[i] = strings.TrimSpace(res[i])
 | 
							res[i] = strings.TrimSpace(res[i])
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user