Beispiel #1
0
func TestSplitDomainHead(t *testing.T) {
	for i := range items {
		head, rest := util.SplitDomainHead(items[i].input)
		tail, trest := util.SplitDomainTail(items[i].input)
		if head != items[i].expectedHead {
			t.Errorf("Input \"%s\": head \"%s\" does not equal expected value \"%s\"", items[i].input, head, items[i].expectedHead)
		}
		if rest != items[i].expectedRest {
			t.Errorf("Input \"%s\": rest \"%s\" does not equal expected value \"%s\"", items[i].input, rest, items[i].expectedRest)
		}
		if tail != items[i].expectedTail {
			t.Errorf("Input \"%s\": tail \"%s\" does not equal expected value \"%s\"", items[i].input, tail, items[i].expectedTail)
		}
		if trest != items[i].expectedTailRest {
			t.Errorf("Input \"%s\": tail rest \"%s\" does not equal expected value \"%s\"", items[i].input, trest, items[i].expectedTailRest)
		}
	}
}
Beispiel #2
0
func (v *Value) qualifyIntl(name, suffix, apexSuffix string) string {
	if strings.HasSuffix(name, ".") {
		return name
	}

	if !v.IsTopLevel {
		_, suffix = util.SplitDomainTail(suffix)
	}

	if name == "" {
		return suffix
	}

	if name == "@" {
		return apexSuffix
	}

	if strings.HasSuffix(name, ".@") {
		return name[0:len(name)-2] + "." + apexSuffix
	}

	return name + "." + suffix
}