That’s a good question because it’s easy to expect the same result from both of those values.
So in Bases, a link is not some long string that happens to have square brackets. A link is its own kind of entity. It is a link type. So regardless of whether they have display text, both [[MATCH]] and [[title|MATCH]] are link type values. The first is a link to MATCH.md and the second a link to title.md.
Your second value requires toString because your aim is to look in the string “[[title|MATCH]]” for the substring “MATCH”.
But without toString, you’re looking in the link[[title|MATCH]]. Since a link isn’t a string and doesn’t contain substrings, there’s no “MATCH” to be found. That is, until you toString it, which outputs a string that you can parse for substrings.
⁂
As for why the first value returns true without toString…
When you perform "[[MATCH]]".contains("MATCH"), Bases is able to resolve that as “list contains link” and returns true.
(edit:)
After posting, I thought to test a third value, [[MATCH|lorem]], which returns true both with and without toString. I also thought to create an error on "[[title|MATCH]]" so that the error message would tell me its type. It’s a list.
So I’m now pretty confident in the reasoning and deleted a bunch of weasel-wording that I used.
thank you very much, especially for taking the time to explain the circumstances to me. I really appreciate this.
I understand it a little better now from a technical standpoint. As a mere user, I am still confused by the mixed results.
Anyhow, I wonder if the approach I chose with toString() is the correct procedure, or if I have a list with wiki links and also want to check their “display names” (the part afer “|”), another approach might be better.
It suits your goal of finding “MATCH” in either the display text or the note’s name.
Bases doesn’t have a function for returning a link’s display text separately from the note name. But if you ever do want to separate the two, then looking at the note name exclusive of the display text is as simple as
list_property.contains(link("MATCH"))
This also works:
list_property.filter(value == link("MATCH"))
Looking at the display text exclusive of the note name, however, is a fine time to use regex. Or take the long way around with a filter like: