MCPcopy Create free account
hub / github.com/decaporg/decap-cms / encode

Function encode

packages/decap-cms-lib-util/src/notesFormat.ts:29–31  ·  view source on GitHub ↗

* A JSON string may contain `-->`, which would close the HTML comment early. * Escaping every hyphen that precedes another removes every `--`, so `-->` * cannot survive; `JSON.parse` decodes `\u002d` back, so it stays lossless * and a lone hyphen (`Jean-Luc`) stays readable. * * Replacing `--`

(payload: Record<string, unknown>)

Source from the content-addressed store, hash-verified

27 * behind at the seam.
28 */
29function encode(payload: Record<string, unknown>) {
30 return JSON.stringify(payload).replace(/-(?=-)/g, '\\u002d');
31}
32
33export interface ParsedNoteBody {
34 content: string;

Callers 2

formatNoteBodyFunction · 0.85
encodeImageDataFunction · 0.85

Calls 1

replaceMethod · 0.80

Tested by

no test coverage detected