shithub: mycel

Download patch

ref: 86a0926452f9152288b7aa7c283e15772754897e
parent: 912c90f60fc126d091e324de8a16986efaffecaf
author: Philip Silva <philip.silva@protonmail.com>
date: Sun Mar 14 11:16:51 EDT 2021

improved compat comment handling

- don't replace within actual code

--- a/domino/domino.go
+++ b/domino/domino.go
@@ -18,6 +18,7 @@
 	"net/http"
 	"os"
 	"path/filepath"
+	"regexp"
 	"strconv"
 	"strings"
 	"syscall"
@@ -149,7 +150,8 @@
 }
 
 func (d *Domino) Exec(script string, initial bool) (res string, err error) {
-	script = strings.Replace(script, "<!--", "//", -1)
+	r := regexp.MustCompile(`^\s<!--`)
+	script = r.ReplaceAllString(script, "//")
 	SCRIPT := domIntf + script
 	if !initial {
 		SCRIPT = script
--- a/domino/domino_test.go
+++ b/domino/domino_test.go
@@ -729,7 +729,9 @@
 	d := NewDomino(simpleHTML, nil, nil)
 	d.Start()
 	script := `
-<!--
+<!-- This is an actual comment
+
+	''.replace(/^\s*<!--/g, '');
 	const a = 1;
 	a + 7;
 // -->