github.com/blend/go-sdk@v1.20220411.3/stringutil/has_suffix_caseless.go (about) 1 /* 2 3 Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file. 5 6 */ 7 8 package stringutil 9 10 // HasSuffixCaseless returns if a corpus has a suffix regardless of casing. 11 func HasSuffixCaseless(corpus, suffix string) bool { 12 corpusLen := len(corpus) 13 suffixLen := len(suffix) 14 15 if corpusLen < suffixLen { 16 return false 17 } 18 19 for x := 0; x < suffixLen; x++ { 20 charCorpus := uint(corpus[corpusLen-(x+1)]) 21 charSuffix := uint(suffix[suffixLen-(x+1)]) 22 23 if charCorpus-LowerA <= LowerDiff { 24 charCorpus = charCorpus - 0x20 25 } 26 27 if charSuffix-LowerA <= LowerDiff { 28 charSuffix = charSuffix - 0x20 29 } 30 if charCorpus != charSuffix { 31 return false 32 } 33 } 34 return true 35 }