Skip to content

invalid character '\b' in string literal #688

@RampantDespair

Description

@RampantDespair

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:

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions