add api path

This commit is contained in:
Gianni Carafa
2023-11-02 18:25:31 +01:00
parent ca26f6d88d
commit aa1caaca98
4 changed files with 81 additions and 4 deletions

View File

@@ -63,7 +63,7 @@ func rewriteHtml(bodyB []byte, u *url.URL) string {
// scripts
scriptPattern := `<script\s+([^>]*\s+)?src="(/)([^"]*)"`
reScript := regexp.MustCompile(scriptPattern)
body = reScript.ReplaceAllString(body, fmt.Sprintf(`<script $1 script="%s$3"`, "/https://"+u.Host))
body = reScript.ReplaceAllString(body, fmt.Sprintf(`<script $1 script="%s$3"`, "/https://"+u.Host+"/"))
//body = strings.ReplaceAll(body, "srcset=\"/", "srcset=\"/https://"+u.Host+"/") // TODO: Needs a regex to rewrite the URL's
body = strings.ReplaceAll(body, "href=\"/", "href=\"/https://"+u.Host+"/")