summaryrefslogtreecommitdiff
path: root/vendor/github.com/mitchellh/packer/builder/azure/common/gluestrings.go
blob: e3b6963d3bb84a600e66c3f5b395700a0b5a8050 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package common

// removes overlap between the end of a and the start of b and
// glues them together
func GlueStrings(a, b string) string {
	shift := 0
	for shift < len(a) {
		i := 0
		for (i+shift < len(a)) && (i < len(b)) && (a[i+shift] == b[i]) {
			i++
		}
		if i+shift == len(a) {
			break
		}
		shift++
	}

	return a[:shift] + b
}