github.phpd.cn/hashicorp/packer@v1.3.2/builder/azure/common/gluestrings.go (about)

     1  package common
     2  
     3  // removes overlap between the end of a and the start of b and
     4  // glues them together
     5  func GlueStrings(a, b string) string {
     6  	shift := 0
     7  	for shift < len(a) {
     8  		i := 0
     9  		for (i+shift < len(a)) && (i < len(b)) && (a[i+shift] == b[i]) {
    10  			i++
    11  		}
    12  		if i+shift == len(a) {
    13  			break
    14  		}
    15  		shift++
    16  	}
    17  
    18  	return a[:shift] + b
    19  }