github.com/lineaje-labs/syft@v0.98.1-0.20231227153149-9e393f60ff1b/syft/format/common/spdxhelpers/spdxid.go (about)

     1  package spdxhelpers
     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  func SanitizeElementID(id string) string {
    12  	return expr.ReplaceAllString(id, "-")
    13  }