From 6476899764904fc0554fb1acc55cd511379afa18 Mon Sep 17 00:00:00 2001 From: tdurieux Date: Fri, 26 Apr 2024 14:01:46 +0100 Subject: [PATCH] fix: fix webview --- src/core/AnonymizedFile.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/core/AnonymizedFile.ts b/src/core/AnonymizedFile.ts index 34439e5..447206a 100644 --- a/src/core/AnonymizedFile.ts +++ b/src/core/AnonymizedFile.ts @@ -57,14 +57,16 @@ export default class AnonymizedFile { if (this._file) return this._file; let fileDir = dirname(this.anonymizedPath); if (fileDir == ".") fileDir = ""; + if (fileDir.endsWith("/")) fileDir = fileDir.slice(0, -1); const filename = basename(this.anonymizedPath); if (!this.anonymizedPath.includes(config.ANONYMIZATION_MASK)) { - const res = await FileModel.findOne({ + const query: Partial = { repoId: this.repository.repoId, path: fileDir, - name: filename, - }); + }; + if (filename != "") query.name = filename; + const res = await FileModel.findOne(query); if (res) { this._file = res; return res; @@ -143,7 +145,7 @@ export default class AnonymizedFile { } } extension() { - const filename = basename(this.anonymizedPath); + const filename = basename(this._file?.name || this.anonymizedPath); const extensions = filename.split(".").reverse(); return extensions[0].toLowerCase(); }