From 83e4a2fab691929a90c0b9e184960bc6d8d42404 Mon Sep 17 00:00:00 2001 From: Mathias Jakobsen Date: Thu, 26 Jan 2023 10:45:05 +0000 Subject: [PATCH] [web] Try various file extensions for preview urls (#11467) GitOrigin-RevId: 1dd8001c337b10450c83a58b4ab0904867a21250 --- .../js/ide/file-tree/FileTreeManager.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/services/web/frontend/js/ide/file-tree/FileTreeManager.js b/services/web/frontend/js/ide/file-tree/FileTreeManager.js index c4b220dcc0..0ee55474f2 100644 --- a/services/web/frontend/js/ide/file-tree/FileTreeManager.js +++ b/services/web/frontend/js/ide/file-tree/FileTreeManager.js @@ -293,10 +293,21 @@ export default FileTreeManager = class FileTreeManager { } getPreviewUrlByPath(path) { - const entity = this.findEntityByPath(path) - return entity - ? `/project/${this.$scope.project._id}/file/${entity.id}` - : null + for (const extension of [ + '', + '.png', + '.jpg', + '.jpeg', + '.PNG', + '.JPG', + '.JPEG', + ]) { + const entity = this.findEntityByPath(path + extension) + if (entity) { + return `/project/${this.$scope.project._id}/file/${entity.id}` + } + } + return null } _findEntityByPathInFolder(folder, path) {