Documentation
¶
Index ¶
- func GenerateHTMLClayID() (string, error)
- func HasHTMLTag(data []byte) bool
- func InjectHTMLClayID(data []byte, id string) []byte
- func InjectToken(data []byte, value string) []byte
- func IsCompleteHTMLDocument(data []byte) bool
- func ReadHTMLClayID(data []byte) string
- func SetHTMLClayID(data []byte, id string) []byte
- func StripHTMLClayID(data []byte) []byte
- func StripToken(data []byte) []byte
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateHTMLClayID ¶
GenerateHTMLClayID generates a UUID v4 using crypto/rand.
func HasHTMLTag ¶
HasHTMLTag reports whether data contains a real top-level <html> start tag, ignoring any <html occurrence inside a comment. Used to reject a save body that is not a full HTML document before it overwrites a file.
func InjectHTMLClayID ¶
InjectHTMLClayID adds htmlclayid to <html> if not already present. This is persistent — never stripped on save.
func InjectToken ¶
InjectToken injects the htmlclaytoken attribute on <html>. Ephemeral auth token — stripped on save.
func IsCompleteHTMLDocument ¶ added in v1.2.0
IsCompleteHTMLDocument reports whether data is a whole document: a real top-level <html> start tag followed by a matching </html> end tag. HasHTMLTag alone is not sufficient for a restore, because it accepts `<html><body>partial` and would let a truncated version overwrite a good file.
func ReadHTMLClayID ¶
ReadHTMLClayID extracts the htmlclayid UUID from the <html> tag. Returns empty string if not present.
func SetHTMLClayID ¶ added in v1.2.0
SetHTMLClayID forces htmlclayid on <html>, replacing any existing value. Restore uses it to keep the target file's canonical identity rather than adopting the id stored inside the restored version.
func StripHTMLClayID ¶ added in v1.2.0
StripHTMLClayID removes the htmlclayid attribute from <html>. Used when restoring into a file that carries no identity of its own, so a version taken from a different file cannot donate its id.
func StripToken ¶
StripToken removes the htmlclaytoken attribute from <html>.
Types ¶
This section is empty.