internal/phpx: Decrease server code size

This commit is contained in:
Tom Wiesing 2023-01-16 13:48:10 +01:00
parent bcd1805001
commit e4a46658ae
No known key found for this signature in database
2 changed files with 26 additions and 22 deletions

View file

@ -5,6 +5,7 @@ import (
"encoding/json"
"io"
"os"
"regexp"
"strings"
"sync"
@ -233,6 +234,8 @@ var serverPHP string
// pre-process the server.php code to make it shorter
func init() {
minifier := regexp.MustCompile(`\s*([=)(.,{}])\s*`)
// remove the first '<?php' line
lines := strings.Split(serverPHP, "\n")[1:]
for i, line := range lines {
@ -244,5 +247,5 @@ func init() {
return !strings.HasPrefix(line, "//")
})
serverPHP = strings.Join(lines, "")
serverPHP = minifier.ReplaceAllString(strings.Join(lines, ""), "$1")
}