MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / titleLinkLikePattern

Function titleLinkLikePattern

internal/store/documents.go:624–630  ·  view source on GitHub ↗

escapeLikePattern escapes the three characters that carry meaning inside a LIKE pattern, for use with an explicit `ESCAPE '\'` clause. Without this the cascade's own search term is interpreted as a pattern, and a document TITLE decides how (BUG-2798, plus the rest of the class it was an instance of

(title string)

Source from the content-addressed store, hash-verified

622// matches them all. It is a superset by construction, and the rewriter's own
623// matcher is the authority on which rows actually link the title.
624func titleLinkLikePattern(title string) string {
625 parts := strings.Split(links.EscapeWikiTitle(title), `\`)
626 for i := range parts {
627 parts[i] = escapeLikePattern(parts[i])
628 }
629 return "%[[" + strings.Join(parts, "%") + "]]%"
630}
631
632func escapeLikePattern(s string) string {
633 r := strings.NewReplacer(`\`, `\\`, `%`, `\%`, `_`, `\_`)

Callers 1

updateLinksInTxMethod · 0.85

Calls 3

EscapeWikiTitleFunction · 0.92
escapeLikePatternFunction · 0.85
JoinMethod · 0.80

Tested by

no test coverage detected