File: v4.go

package info (click to toggle)
golang-github-emersion-go-vcard 0.0~git20230815.8fda7d2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 136 kB
  • sloc: makefile: 2
file content (30 lines) | stat: -rw-r--r-- 527 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package vcard

import (
	"strings"
)

// See https://github.com/mangstadt/ez-vcard/wiki/Version-differences

// ToV4 converts a card to vCard version 4.
func ToV4(card Card) {
	version := card.Value(FieldVersion)
	if strings.HasPrefix(version, "4.") {
		return
	}

	card.SetValue(FieldVersion, "4.0")

	for k, fields := range card {
		if strings.EqualFold(k, FieldVersion) {
			continue
		}

		for _, f := range fields {
			if f.Params.HasType("pref") {
				delete(f.Params, "pref")
				f.Params.Set("pref", "1")
			}
		}
	}
}