-
-
Notifications
You must be signed in to change notification settings - Fork 226
Closed
Description
This is somewhat of a continuation to #685.
The ast tree produced by minify is unable to be parsed by json for the following 3 objects:
- https://gist.github.com/RampantDespair/d97f6c1e70bcd56a2b2d164857718dc4
- https://gist.github.com/RampantDespair/c00c7750cd93690c46b49734b8fd16c3
- https://gist.github.com/RampantDespair/33dda35da104737596d46bfbdb656a23
The code hasn't changed:
s.bodyParsed = strings.Split(s.bodyParsed, `.ReactDOMrender(`)[1]
s.bodyParsed = strings.Split(s.bodyParsed, `,document.getElementById(`)[0]
s.bodyParsed = fmt.Sprintf("(%s)", s.bodyParsed)
reader := strings.NewReader(s.bodyParsed)
input := parse.NewInput(reader)
astTree, err := js.Parse(input, js.Options{})
if err != nil {
log.Printf("Failed to parse input (%v) -> %s", input, err)
return
}
jsonBody, err := astTree.JSONString()
if err != nil {
Debug("Failed to convert astTree to jsonBody (%s) -> %s", astTree, err) // <---- ERROR THROWN
}
if debug {
os.WriteFile("../test.json", []byte(jsonBody), OS_ALL_RWX)
}
var bodyJson model.PageData
err = json.Unmarshal([]byte(jsonBody), &bodyJson)
if err != nil {
log.Fatal(err)
}
Metadata
Metadata
Assignees
Labels
No labels