Skip to content

Commit

Permalink
feat(js): 读取js脚本信息时去除两端空白
Browse files Browse the repository at this point in the history
  • Loading branch information
JustAnotherID committed Jul 29, 2023
1 parent a934e0c commit e281cf6
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions dice/dice_jsvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,21 +356,22 @@ func (d *Dice) JsLoadScriptRaw(s string, info fs.FileInfo) {
re2 := regexp.MustCompile(`//[ \t]*@(\S+)\s+([^\r\n]+)`)
data := re2.FindAllStringSubmatch(text, -1)
for _, item := range data {
v := strings.TrimSpace(item[2])
switch item[1] {
case "name":
jsInfo.Name = item[2]
jsInfo.Name = v
case "homepageURL":
jsInfo.HomePage = item[2]
jsInfo.HomePage = v
case "license":
jsInfo.License = item[2]
jsInfo.License = v
case "author":
jsInfo.Author = item[2]
jsInfo.Author = v
case "version":
jsInfo.Version = item[2]
jsInfo.Version = v
case "description":
jsInfo.Desc = item[2]
jsInfo.Desc = v
case "timestamp":
v, err := strconv.ParseInt(item[2], 10, 64)
v, err := strconv.ParseInt(v, 10, 64)
if err == nil {
jsInfo.UpdateTime = v
}
Expand Down

0 comments on commit e281cf6

Please sign in to comment.