* Update files in /app * Update files in /plugin * Update files in /store * Update files in /utils * Update files in /web * Update store.go * Update command_response.go * check-mocks and check-store-layer checks * Fix build errors * Revert "Fix build errors" This reverts commit 4ee38c3d0bf7bd7d8386f46f0985a0d03245a1d4. * Update .golangci.yml * make i18n-extract and make i18n-check * Commit suggestions * check-mocks and check-store-layers * Update en.json * Update product_notices.go * Update main.go * Fix translations * Regenerate mocks Co-authored-by: Mattermod <mattermod@users.noreply.github.com> Co-authored-by: Claudio Costa <cstcld91@gmail.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
5f190b5624
Коммит
6356e906e0
@@ -62,8 +62,8 @@ func UpdateAssetsSubpathInDir(subpath, directory string) error {
|
||||
return errors.Wrapf(err, "failed to resolve symlinks to %s", staticDir)
|
||||
}
|
||||
|
||||
rootHtmlPath := filepath.Join(staticDir, "root.html")
|
||||
oldRootHtml, err := ioutil.ReadFile(rootHtmlPath)
|
||||
rootHTMLPath := filepath.Join(staticDir, "root.html")
|
||||
oldRootHTML, err := ioutil.ReadFile(rootHTMLPath)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to open root.html")
|
||||
}
|
||||
@@ -73,7 +73,7 @@ func UpdateAssetsSubpathInDir(subpath, directory string) error {
|
||||
// Determine if a previous subpath had already been rewritten into the assets.
|
||||
reWebpackPublicPathScript := regexp.MustCompile("window.publicPath='([^']+/)static/'")
|
||||
alreadyRewritten := false
|
||||
if matches := reWebpackPublicPathScript.FindStringSubmatch(string(oldRootHtml)); matches != nil {
|
||||
if matches := reWebpackPublicPathScript.FindStringSubmatch(string(oldRootHTML)); matches != nil {
|
||||
oldSubpath = matches[1]
|
||||
alreadyRewritten = true
|
||||
}
|
||||
@@ -83,14 +83,14 @@ func UpdateAssetsSubpathInDir(subpath, directory string) error {
|
||||
|
||||
mlog.Debug("Rewriting static assets", mlog.String("from_subpath", oldSubpath), mlog.String("to_subpath", subpath))
|
||||
|
||||
newRootHtml := string(oldRootHtml)
|
||||
newRootHTML := string(oldRootHTML)
|
||||
|
||||
reCSP := regexp.MustCompile(`<meta http-equiv="Content-Security-Policy" content="script-src 'self' cdn.rudderlabs.com/ js.stripe.com/v3([^"]*)">`)
|
||||
if results := reCSP.FindAllString(newRootHtml, -1); len(results) == 0 {
|
||||
if results := reCSP.FindAllString(newRootHTML, -1); len(results) == 0 {
|
||||
return fmt.Errorf("failed to find 'Content-Security-Policy' meta tag to rewrite")
|
||||
}
|
||||
|
||||
newRootHtml = reCSP.ReplaceAllLiteralString(newRootHtml, fmt.Sprintf(
|
||||
newRootHTML = reCSP.ReplaceAllLiteralString(newRootHTML, fmt.Sprintf(
|
||||
`<meta http-equiv="Content-Security-Policy" content="script-src 'self' cdn.rudderlabs.com/ js.stripe.com/v3%s">`,
|
||||
GetSubpathScriptHash(subpath),
|
||||
))
|
||||
@@ -98,22 +98,22 @@ func UpdateAssetsSubpathInDir(subpath, directory string) error {
|
||||
// Rewrite the root.html references to `/static/*` to include the given subpath.
|
||||
// This potentially includes a previously injected inline script that needs to
|
||||
// be updated (and isn't covered by the cases above).
|
||||
newRootHtml = strings.Replace(newRootHtml, pathToReplace, newPath, -1)
|
||||
newRootHTML = strings.Replace(newRootHTML, pathToReplace, newPath, -1)
|
||||
|
||||
if alreadyRewritten && subpath == "/" {
|
||||
// Remove the injected script since no longer required. Note that the rewrite above
|
||||
// will have affected the script, so look for the new subpath, not the old one.
|
||||
oldScript := getSubpathScript(subpath)
|
||||
newRootHtml = strings.Replace(newRootHtml, fmt.Sprintf("</style><script>%s</script>", oldScript), "</style>", 1)
|
||||
newRootHTML = strings.Replace(newRootHTML, fmt.Sprintf("</style><script>%s</script>", oldScript), "</style>", 1)
|
||||
|
||||
} else if !alreadyRewritten && subpath != "/" {
|
||||
// Otherwise, inject the script to define `window.publicPath`.
|
||||
script := getSubpathScript(subpath)
|
||||
newRootHtml = strings.Replace(newRootHtml, "</style>", fmt.Sprintf("</style><script>%s</script>", script), 1)
|
||||
newRootHTML = strings.Replace(newRootHTML, "</style>", fmt.Sprintf("</style><script>%s</script>", script), 1)
|
||||
}
|
||||
|
||||
// Write out the updated root.html.
|
||||
if err = ioutil.WriteFile(rootHtmlPath, []byte(newRootHtml), 0); err != nil {
|
||||
if err = ioutil.WriteFile(rootHTMLPath, []byte(newRootHTML), 0); err != nil {
|
||||
return errors.Wrapf(err, "failed to update root.html with subpath %s", subpath)
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user