diff --git a/server.js b/server.js index edbf138..31c303e 100644 --- a/server.js +++ b/server.js @@ -85,16 +85,17 @@ const hbs = create({ return process.env.MASTODON_ACCOUNT; }, ifIn(item, array, options) { - return array.indexOf(item) >= 0 ? options.fn(this) : options.inverse(this); + const lowercased = array.map((tag) => tag.toLowerCase()); + return lowercased.indexOf(item.toLowerCase()) >= 0 ? options.fn(this) : options.inverse(this); }, removeTag(tag, path) { return path .split('/') - .filter((x) => x !== tag) + .filter((x) => x.toLowerCase() !== tag.toLowerCase()) .join('/'); }, ifThisTag(tag, path, options) { - return path === `/tagged/${tag}` ? options.fn(this) : options.inverse(this); + return path.toLowerCase() === `/tagged/${tag}`.toLowerCase() ? options.fn(this) : options.inverse(this); }, eq(a, b, options) { return a === b ? options.fn(this) : options.inverse(this); diff --git a/src/bookmarks-db.js b/src/bookmarks-db.js index d03dc18..8689b0a 100644 --- a/src/bookmarks-db.js +++ b/src/bookmarks-db.js @@ -215,7 +215,7 @@ export async function getBookmarksForCSVExport() { export async function getBookmarkCountForTags(tags) { const tagClauses = tags.map(() => `(tags like ? OR tags like ?)`).join(' AND '); - const tagParams = tags.map((tag) => [`%${tag}% `, `%${tag}%`]).flat(); + const tagParams = tags.map((tag) => [`%#${tag} %`, `%#${tag}`]).flat(); const result = await db.get.apply(db, [`SELECT count(id) as count from bookmarks WHERE ${tagClauses}`, ...tagParams]); return result?.count; } @@ -224,7 +224,7 @@ export async function getBookmarksForTags(tags, limit = 10, offset = 0) { // We use a try catch block in case of db errors try { const tagClauses = tags.map(() => `(tags like ? OR tags like ?)`).join(' AND '); - const tagParams = tags.map((tag) => [`%${tag}% `, `%${tag}%`]).flat(); + const tagParams = tags.map((tag) => [`%#${tag} %`, `%#${tag}`]).flat(); const results = await db.all.apply(db, [ `SELECT * from bookmarks WHERE ${tagClauses} ORDER BY updated_at DESC LIMIT ? OFFSET ?`, ...tagParams,