github.com/anchore/syft@v1.38.2/syft/format/internal/spdxutil/helpers/spdxid.go (about)

     1  package helpers
     2  
     3  import (
     4  	"regexp"
     5  )
     6  
     7  var expr = regexp.MustCompile("[^a-zA-Z0-9.-]")
     8  
     9  // SPDX spec says SPDXID must be:
    10  // "SPDXRef-"[idstring] where [idstring] is a unique string containing letters, numbers, ., and/or -
    11  // https://spdx.github.io/spdx-spec/v2.3/snippet-information/
    12  func SanitizeElementID(id string) string {
    13  	return expr.ReplaceAllString(id, "-")
    14  }