diff --git a/src/Icons/Controllers/IconsController.cs b/src/Icons/Controllers/IconsController.cs index 350af4111b..e414d67ec1 100644 --- a/src/Icons/Controllers/IconsController.cs +++ b/src/Icons/Controllers/IconsController.cs @@ -48,13 +48,15 @@ namespace Bit.Icons.Controllers var result = await _iconFetchingService.GetIconAsync(mappedDomain); if(result == null) { - return new NotFoundResult(); + icon = null; + } + else + { + icon = result.Icon; } - icon = result.Icon; - - // Only cache smaller images (<= 50kb) - if(icon.Image.Length <= 50012) + // Only cache not found and smaller images (<= 50kb) + if(icon == null || icon.Image.Length <= 50012) { _memoryCache.Set(mappedDomain, icon, new MemoryCacheEntryOptions { @@ -63,6 +65,11 @@ namespace Bit.Icons.Controllers } } + if(icon == null) + { + return new NotFoundResult(); + } + return new FileContentResult(icon.Image, icon.Format); } }