Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

chore: make sure keyword matching is case insentive

Marc Seitz2fcfd90ab137
diff --git a/lib/api/documents/process-document.ts b/lib/api/documents/process-document.ts
index 8fa4be4a..e99d7f33 100644
--- a/lib/api/documents/process-document.ts
+++ b/lib/api/documents/process-document.ts
@@ -88,7 +88,9 @@ export const processDocument = async ({
const keywords = await get("keywords");
if (Array.isArray(keywords) && keywords.length > 0) {
const matchedKeyword = keywords.find(
- (keyword) => typeof keyword === "string" && key.includes(keyword),
+ (keyword) =>
+ typeof keyword === "string" &&
+ key.toLowerCase().includes(keyword.toLowerCase()),
);
if (matchedKeyword) {
diff --git a/lib/api/domains/validate-redirect-url.ts b/lib/api/domains/validate-redirect-url.ts
index aa2aee37..f972ad06 100644
--- a/lib/api/domains/validate-redirect-url.ts
+++ b/lib/api/domains/validate-redirect-url.ts
@@ -42,7 +42,9 @@ export async function validateRedirectUrl(
const keywords = await get("keywords");
if (Array.isArray(keywords) && keywords.length > 0) {
const matchedKeyword = keywords.find(
- (keyword) => typeof keyword === "string" && trimmed.includes(keyword),
+ (keyword) =>
+ typeof keyword === "string" &&
+ trimmed.toLowerCase().includes(keyword.toLowerCase()),
);
if (matchedKeyword) {
diff --git a/pages/api/mupdf/convert-page.ts b/pages/api/mupdf/convert-page.ts
index 3ae4b368..b49fddc3 100644
--- a/pages/api/mupdf/convert-page.ts
+++ b/pages/api/mupdf/convert-page.ts
@@ -179,7 +179,8 @@ export default async (req: NextApiRequest, res: NextApiResponse) => {
if (link.href) {
const matchedKeyword = keywords.find(
(keyword) =>
- typeof keyword === "string" && link.href.includes(keyword),
+ typeof keyword === "string" &&
+ link.href.toLowerCase().includes(keyword.toLowerCase()),
);
if (matchedKeyword) {
diff --git a/pages/api/teams/[teamId]/documents/[id]/update-link-url.ts b/pages/api/teams/[teamId]/documents/[id]/update-link-url.ts
index e8733672..b9e5cf83 100644
--- a/pages/api/teams/[teamId]/documents/[id]/update-link-url.ts
+++ b/pages/api/teams/[teamId]/documents/[id]/update-link-url.ts
@@ -89,7 +89,8 @@ export default async function handle(
if (Array.isArray(keywords) && keywords.length > 0) {
const matchedKeyword = keywords.find(
(keyword) =>
- typeof keyword === "string" && validatedUrl.includes(keyword),
+ typeof keyword === "string" &&
+ validatedUrl.toLowerCase().includes(keyword.toLowerCase()),
);
if (matchedKeyword) {