fix: make the repoId case insensitive

This commit is contained in:
tdurieux
2023-06-26 18:17:49 +02:00
parent e24d1b4630
commit f54b9f355b
3 changed files with 21 additions and 2 deletions

View File

@@ -3,7 +3,7 @@ import { Schema } from "mongoose";
const AnonymizedRepositorySchema = new Schema({
repoId: {
type: String,
index: { unique: true },
index: { unique: true, collation: { locale: "en", strength: 2 } },
},
status: {
type: String,

View File

@@ -42,7 +42,13 @@ export async function getRepository(
if (!opts.includeFiles) {
project.originalFiles = 0;
}
const data = await AnonymizedRepositoryModel.findOne({ repoId }, project);
const data = await AnonymizedRepositoryModel.findOne(
{ repoId },
project
).collation({
locale: "en",
strength: 2,
});
if (!data)
throw new AnonymousError("repo_not_found", {
object: repoId,