.RS
.PD 0
.IP ":open \fB!\fPfoo ba"
-will match all bookmark that have the tags "foo" or "foot" and tags starting
-with "ba" like "ball".
+will match all bookmark that have tags starting with "foo" and "ba".
+If the bookmark does not have any tags set, the URL is split on `.' and `/'
+into tags.
.PD
.RE
.TP
}
/**
- * Checks if the given bookmark have all given query strings as prefix.
+ * Checks if the given bookmark matches all given query strings as prefix. If
+ * the bookmark has no tags, the matching is done on the '/' splited URL.
*
* @bm: bookmark to test if it matches
* @query: char array with tags to search for
static gboolean bookmark_contains_all_tags(Bookmark *bm, char **query,
unsigned int qlen)
{
+ const char *separators;
+ char *cursor;
unsigned int i;
gboolean found;
if (!qlen) {
return true;
}
- /* don't use bookmarks without tags if tags are used to filter */
- if (!bm->tags) {
- return false;
+
+ if (bm->tags) {
+ /* If there are tags - use them for matching. */
+ separators = " ";
+ cursor = bm->tags;
+ } else {
+ /* No tags available - matching is based on the path parts of the URL. */
+ separators = "./";
+ cursor = bm->uri;
}
/* iterate over all query parts */
for (i = 0; i < qlen; i++) {
- /* put the cursor to the tags string of the bookmarks */
- char *cursor = bm->tags;
- found = false;
+ found = false;
/* we want to do a prefix match on all bookmark tags - so we check for
* a match on string begin - if this fails we move the cursor to the
found = true;
break;
}
- /* if match was not found at the cursor position - move cursor
- * behind the next space */
- if ((cursor = strchr(cursor, ' '))) {
+ /* If match was not found at the cursor position - move cursor
+ * behind the next separator char. */
+ if ((cursor = strpbrk(cursor, separators))) {
cursor++;
}
}