MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / BodyHasLocalAsset

Function BodyHasLocalAsset

apps/server/internal/vault/parse.go:128–157  ·  view source on GitHub ↗

BodyHasLocalAsset is the same cheap heuristic as the TS version.

(body string)

Source from the content-addressed store, hash-verified

126
127// BodyHasLocalAsset is the same cheap heuristic as the TS version.
128func BodyHasLocalAsset(body string) bool {
129 if !strings.Contains(body, "](") && !strings.Contains(body, "![[") {
130 return false
131 }
132 stripped := stripCodeContent(body)
133 for _, m := range linkRe.FindAllStringSubmatch(stripped, -1) {
134 if len(m) < 3 {
135 continue
136 }
137 href := strings.TrimSpace(m[2])
138 if href == "" || strings.HasPrefix(href, "#") || strings.HasPrefix(href, "//") {
139 continue
140 }
141 if matched, _ := regexpMatchScheme(href); matched {
142 continue
143 }
144 if localAssetTargetKind(href) != "" {
145 return true
146 }
147 }
148 for _, m := range embedRe.FindAllStringSubmatch(stripped, -1) {
149 if len(m) < 2 {
150 continue
151 }
152 if localAssetTargetKind(strings.TrimSpace(m[1])) != "" {
153 return true
154 }
155 }
156 return false
157}
158
159var schemeRe = regexp.MustCompile(`^[a-zA-Z][a-zA-Z\d+.\-]*:`)
160

Callers 2

buildNoteMetaFunction · 0.85

Calls 3

regexpMatchSchemeFunction · 0.85
stripCodeContentFunction · 0.70
localAssetTargetKindFunction · 0.70