github.com/noqcks/syft@v0.0.0-20230920222752-a9e2c4e288e5/syft/formats/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  }