We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8a04c27 commit b2e74f6Copy full SHA for b2e74f6
1 file changed
apps/api/src/media/queries.ts
@@ -4,6 +4,10 @@ import GetPageProps from "./GetPageProps";
4
import MediaModel from "./model";
5
import { Constants, type MediaWithUserId } from "@medialit/models";
6
7
+function escapeRegex(value: string): string {
8
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
9
+}
10
+
11
export async function getMedia({
12
userId,
13
apikey,
@@ -89,8 +93,8 @@ export async function getPaginatedMedia({
89
93
? Constants.AccessControl.PRIVATE
90
94
: Constants.AccessControl.PUBLIC;
91
95
}
92
- if (group) {
- query.group = group;
96
+ if (typeof group === "string" && group.trim().length > 0) {
97
+ query.group = { $regex: `^${escapeRegex(group.trim())}` };
98
99
const limitWithFallback = recordsPerPage || numberOfRecordsPerPage;
100
0 commit comments