MCPcopy Create free account
hub / github.com/cortexkit/magic-context / normalize_hash

Function normalize_hash

packages/dashboard/src-tauri/src/db.rs:787–793  ·  view source on GitHub ↗

Compute a normalized hash matching the plugin's dedup logic: lowercase → trim whitespace → hash as hex string. Uses std::hash for portability (no SHA crate in deps); the exact hash algorithm doesn't matter as long as it's consistent within the dashboard. The plugin uses its own Bun-based hash path. Match the plugin's `computeNormalizedHash`: lowercase → collapse whitespace → trim → MD5 hex.

(content: &str)

Source from the content-addressed store, hash-verified

785/// the dashboard. The plugin uses its own Bun-based hash path.
786/// Match the plugin's `computeNormalizedHash`: lowercase → collapse whitespace → trim → MD5 hex.
787fn normalize_hash(content: &str) -> String {
788 let normalized = content.to_lowercase();
789 // Collapse all whitespace runs into a single space (mirrors JS /\s+/g → " ")
790 let normalized: String = normalized.split_whitespace().collect::<Vec<_>>().join(" ");
791 let digest = md5::compute(normalized.as_bytes());
792 format!("{:032x}", digest)
793}
794
795fn format_timestamp_iso(timestamp: i64) -> String {
796 chrono::DateTime::<chrono::Utc>::from_timestamp_millis(timestamp)

Callers 1

update_memory_contentFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected