diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2022-02-28 05:02:17 +0100 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2022-02-28 05:05:52 +0100 |
commit | 7a2ea02c8d5c96c70f6d7098d316b12c00e7c9fc (patch) | |
tree | 9aa13deee37baefbef0c7c6d09fb7982f80a9e37 /hswg | |
parent | bafd5ef22167527e1bde8aed09b09b62278059b0 (diff) | |
download | haven-7a2ea02c8d5c96c70f6d7098d316b12c00e7c9fc.tar.gz haven-7a2ea02c8d5c96c70f6d7098d316b12c00e7c9fc.tar.xz haven-7a2ea02c8d5c96c70f6d7098d316b12c00e7c9fc.zip |
hswg: make AttrList return nil for missing attrs
And update copyright years.
Diffstat (limited to 'hswg')
-rw-r--r-- | hswg/main.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/hswg/main.go b/hswg/main.go index e4b557f..88ed486 100644 --- a/hswg/main.go +++ b/hswg/main.go @@ -49,6 +49,10 @@ func (m *Metadata) Attr(name string) string { // AttrList is similar to Attr, but splits the result at commas, // and trims whitespace around array elements. func (m *Metadata) AttrList(name string) []string { + if !m.Attributes.Has(name) { + return nil + } + res := strings.Split(m.Attr(name), ",") for i := range res { res[i] = strings.TrimSpace(res[i]) |