From e281cf6ee2f9f1cdc4edf6bd879fae5060baa489 Mon Sep 17 00:00:00 2001 From: JustAnotherID Date: Sat, 29 Jul 2023 18:17:01 +0800 Subject: [PATCH] =?UTF-8?q?feat(js):=20=E8=AF=BB=E5=8F=96js=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E4=BF=A1=E6=81=AF=E6=97=B6=E5=8E=BB=E9=99=A4=E4=B8=A4?= =?UTF-8?q?=E7=AB=AF=E7=A9=BA=E7=99=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dice/dice_jsvm.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/dice/dice_jsvm.go b/dice/dice_jsvm.go index 7e03b044..8ea23ff3 100644 --- a/dice/dice_jsvm.go +++ b/dice/dice_jsvm.go @@ -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 }