github.com/mutagen-io/mutagen@v0.18.0-rc1/pkg/environment/block.go (about)

     1  package environment
     2  
     3  import (
     4  	"strings"
     5  )
     6  
     7  // ParseBlock parses an environment variable block of the form
     8  // VAR1=value1[\r]\nVAR2=value2[\r]\n... into a slice of KEY=value strings. It
     9  // opts for performance over extensive format validation.
    10  func ParseBlock(block string) []string {
    11  	// Replace all instances of \r\n with \n.
    12  	block = strings.ReplaceAll(block, "\r\n", "\n")
    13  
    14  	// Trim whitespace from around the block.
    15  	block = strings.TrimSpace(block)
    16  
    17  	// Split the block into individual lines.
    18  	return strings.Split(block, "\n")
    19  }