mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-07-08 14:47:59 +02:00
fix: make the repoId case insensitive
This commit is contained in:
@@ -3,7 +3,7 @@ import { Schema } from "mongoose";
|
|||||||
const AnonymizedRepositorySchema = new Schema({
|
const AnonymizedRepositorySchema = new Schema({
|
||||||
repoId: {
|
repoId: {
|
||||||
type: String,
|
type: String,
|
||||||
index: { unique: true },
|
index: { unique: true, collation: { locale: "en", strength: 2 } },
|
||||||
},
|
},
|
||||||
status: {
|
status: {
|
||||||
type: String,
|
type: String,
|
||||||
|
|||||||
@@ -42,7 +42,13 @@ export async function getRepository(
|
|||||||
if (!opts.includeFiles) {
|
if (!opts.includeFiles) {
|
||||||
project.originalFiles = 0;
|
project.originalFiles = 0;
|
||||||
}
|
}
|
||||||
const data = await AnonymizedRepositoryModel.findOne({ repoId }, project);
|
const data = await AnonymizedRepositoryModel.findOne(
|
||||||
|
{ repoId },
|
||||||
|
project
|
||||||
|
).collation({
|
||||||
|
locale: "en",
|
||||||
|
strength: 2,
|
||||||
|
});
|
||||||
if (!data)
|
if (!data)
|
||||||
throw new AnonymousError("repo_not_found", {
|
throw new AnonymousError("repo_not_found", {
|
||||||
object: repoId,
|
object: repoId,
|
||||||
|
|||||||
@@ -441,6 +441,19 @@ router.post("/", async (req: express.Request, res: express.Response) => {
|
|||||||
const repoUpdate = req.body;
|
const repoUpdate = req.body;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
try {
|
||||||
|
await db.getRepository(repoUpdate.repoId, { includeFiles: false });
|
||||||
|
throw new AnonymousError("repoId_already_used", {
|
||||||
|
httpStatus: 400,
|
||||||
|
object: repoUpdate,
|
||||||
|
});
|
||||||
|
} catch (error: any) {
|
||||||
|
if (error.message == "repo_not_found") {
|
||||||
|
// the repository does not exist yet
|
||||||
|
} else {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
validateNewRepo(repoUpdate);
|
validateNewRepo(repoUpdate);
|
||||||
|
|
||||||
const r = gh(repoUpdate.fullName);
|
const r = gh(repoUpdate.fullName);
|
||||||
|
|||||||
Reference in New Issue
Block a user