gui: a proxy's web page regexps compile when first used (TestNoEagerPackageRegexps)

059d995d5 added webPageStart and webPageTitle as package-level
regexp.MustCompile, which TestNoEagerPackageRegexps refuses: every
package regexp goes through lazyre so start-up doesn't compile them.
CI at 61a04f42a was red on ubuntu and macOS for it.

Run (Windows box, win-run; mote is out of disk and refuses ssh):
- go test -run TestNoEagerPackageRegexps . : ok (red on CI before)
- go test -run 'TestFailSaysAProxyPage|WebPage' -v ./internal/gui:
  TestFailSaysAProxyPageByItsTitle, TestWebPageHandlerEveryWhere pass
- go vet ./internal/gui, gofmt -l: clean
This commit is contained in:
yetone
2026-11-11 14:33:37 +08:00
parent f5e1b10913
commit d62220d43e
+4 -3
View File
@@ -2,13 +2,14 @@ package gui
import (
"html"
"regexp"
"strings"
"github.com/yetone/magpie/internal/lazyre"
)
var (
webPageStart = regexp.MustCompile(`(?i)<(!doctype|html|head|body)\b`)
webPageTitle = regexp.MustCompile(`(?is)<title[^>]*>(.*?)</title>`)
webPageStart = lazyre.New(`(?i)<(!doctype|html|head|body)\b`)
webPageTitle = lazyre.New(`(?is)<title[^>]*>(.*?)</title>`)
)
// webPageSaid is a proxy's own web page inside an error text of magpie's: