Skip to content

Commit

Permalink
Add check for license string length
Browse files Browse the repository at this point in the history
  • Loading branch information
namandf committed Aug 10, 2023
1 parent 029dcfe commit 176caa8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pkg/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
)

const updateInterval = time.Hour * 72 // 3 days
const licenseStringLimit = 50

type Builder struct {
db db.DB
Expand Down Expand Up @@ -121,11 +122,13 @@ func (b *Builder) processLicenseInformationFromCache(license, licenseDir string,
}

// precautionary check
// return first 50 characters if license string is too long
// return first <licenseStringLimit> characters if license string is too long
result := strings.Join(updatedLicenseList, "|")
if len(result) > 50 {
if len(result) > licenseStringLimit {
r := []rune(result)
return string(r[:50])
if len(r) > licenseStringLimit {
return string(r[:licenseStringLimit])
}

}

Expand Down

0 comments on commit 176caa8

Please sign in to comment.