...

Source file src/github.com/aws/smithy-go/endpoints/private/rulesfn/strings.go

Documentation: github.com/aws/smithy-go/endpoints/private/rulesfn

     1  package rulesfn
     2  
     3  // Substring returns the substring of the input provided. If the start or stop
     4  // indexes are not valid for the input nil will be returned. If errors occur
     5  // they will be added to the provided [ErrorCollector].
     6  func SubString(input string, start, stop int, reverse bool) *string {
     7  	if start < 0 || stop < 1 || start >= stop || len(input) < stop {
     8  		return nil
     9  	}
    10  
    11  	for _, r := range input {
    12  		if r > 127 {
    13  			return nil
    14  		}
    15  	}
    16  
    17  	if !reverse {
    18  		v := input[start:stop]
    19  		return &v
    20  	}
    21  
    22  	rStart := len(input) - stop
    23  	rStop := len(input) - start
    24  	return SubString(input, rStart, rStop, false)
    25  }
    26  

View as plain text