Fix 9 bugs and add 103 tests for core anonymization, config, and routing (#669)

This commit is contained in:
Thomas Durieux
2026-04-15 09:41:00 +02:00
committed by GitHub
parent 261eaa8d79
commit 188066e91d
23 changed files with 2630 additions and 39 deletions
+10 -5
View File
@@ -129,10 +129,10 @@ router.get("/repos", async (req, res) => {
}
const query = [];
if (req.query.search) {
query.push({ repoId: { $regex: req.query.search } });
const escaped = (req.query.search as string).replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
query.push({ repoId: { $regex: escaped } });
}
const status: { status: string }[] = [];
query.push({ $or: status });
if (ready) {
status.push({ status: "ready" });
}
@@ -151,6 +151,9 @@ router.get("/repos", async (req, res) => {
status.push({ status: "preparing" });
status.push({ status: "download" });
}
if (status.length > 0) {
query.push({ $or: status });
}
const skipIndex = (page - 1) * limit;
const [total, results] = await Promise.all([
AnonymizedRepositoryModel.find({
@@ -199,7 +202,8 @@ router.get("/users", async (req, res) => {
}
let query = {};
if (req.query.search) {
query = { username: { $regex: req.query.search } };
const escaped = (req.query.search as string).replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
query = { username: { $regex: escaped } };
}
res.json({
@@ -270,10 +274,11 @@ router.get("/conferences", async (req, res) => {
}
let query = {};
if (req.query.search) {
const escaped = (req.query.search as string).replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
query = {
$or: [
{ name: { $regex: req.query.search } },
{ conferenceID: { $regex: req.query.search } },
{ name: { $regex: escaped } },
{ conferenceID: { $regex: escaped } },
],
};
}