aboutsummaryrefslogtreecommitdiff
path: root/file.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2026-01-12 23:01:35 +0700
committerShulhan <ms@kilabit.info>2026-01-12 23:01:35 +0700
commite16e2a4ec74443aa8f4c21a73ee837cb72ed46fb (patch)
tree8458e4f7bc3803310f1e4071a28a70bb8f0fd939 /file.go
parent9817757f8dca159aa261315a91fceff1d9a13566 (diff)
downloadspdxconv-e16e2a4ec74443aa8f4c21a73ee837cb72ed46fb.tar.xz
all: fix default regex match license and copyright to ignore comment
Instead of assuming that the comment prefix and space always exists "^(//)\s+..." change it to be optional, so it will works on the multi-line comment. For example, comment and old headers in html, <-- Copyright ... --> there is no comment prefix and space.
Diffstat (limited to 'file.go')
-rw-r--r--file.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/file.go b/file.go
index 7849d9e..798790c 100644
--- a/file.go
+++ b/file.go
@@ -187,18 +187,20 @@ func (f *file) scanCopyrightText(conv *SPDXConv) {
}
if cmc.match(string(line)) {
f.idxCopyrightText = x
+ f.copyrightYear = cmc.year
f.copyrightText = valMatch
return
}
}
for x, line := range f.bottomLines {
- if reLicenseID.Match(line) {
+ if reCopyrightText.Match(line) {
f.idxCopyrightText = x - conv.cfg.MaxLineMatch
f.copyrightText = valExist
return
}
if cmc.match(string(line)) {
f.idxCopyrightText = x - conv.cfg.MaxLineMatch
+ f.copyrightYear = cmc.year
f.copyrightText = valMatch
return
}