mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 23:51:44 +08:00
22 lines
441 B
Go
22 lines
441 B
Go
package assetserver
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
func injectScript(input string, script string) ([]byte, error) {
|
|
splits := strings.Split(input, "<head>")
|
|
if len(splits) != 2 {
|
|
return nil, fmt.Errorf("unable to locate a </head> tag in your html")
|
|
}
|
|
|
|
var result bytes.Buffer
|
|
result.WriteString(splits[0])
|
|
result.WriteString("<head>")
|
|
result.WriteString(script)
|
|
result.WriteString(splits[1])
|
|
return result.Bytes(), nil
|
|
}
|