mirror of
				https://github.com/go-gitea/gitea
				synced 2025-10-31 03:18:24 +00:00 
			
		
		
		
	* Fix validate() function to handle errors in embedded anon structs * Implement webhook branch filter See #2025, #3998.
		
			
				
	
	
		
			36 lines
		
	
	
		
			530 B
		
	
	
	
		
			Go
		
	
	
	
		
			Vendored
		
	
	
	
			
		
		
	
	
			36 lines
		
	
	
		
			530 B
		
	
	
	
		
			Go
		
	
	
	
		
			Vendored
		
	
	
	
| package match
 | |
| 
 | |
| import (
 | |
| 	"fmt"
 | |
| 	"strings"
 | |
| )
 | |
| 
 | |
| type Suffix struct {
 | |
| 	Suffix string
 | |
| }
 | |
| 
 | |
| func NewSuffix(s string) Suffix {
 | |
| 	return Suffix{s}
 | |
| }
 | |
| 
 | |
| func (self Suffix) Len() int {
 | |
| 	return lenNo
 | |
| }
 | |
| 
 | |
| func (self Suffix) Match(s string) bool {
 | |
| 	return strings.HasSuffix(s, self.Suffix)
 | |
| }
 | |
| 
 | |
| func (self Suffix) Index(s string) (int, []int) {
 | |
| 	idx := strings.Index(s, self.Suffix)
 | |
| 	if idx == -1 {
 | |
| 		return -1, nil
 | |
| 	}
 | |
| 
 | |
| 	return 0, []int{idx + len(self.Suffix)}
 | |
| }
 | |
| 
 | |
| func (self Suffix) String() string {
 | |
| 	return fmt.Sprintf("<suffix:%s>", self.Suffix)
 | |
| }
 |