From 4c3c594603acb39ce473ef2ea69b6583e6a69478 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Thu, 12 Oct 2017 10:00:44 -0400 Subject: [PATCH] use png extension for CDN caching --- src/Icons/Controllers/IconsController.cs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/Icons/Controllers/IconsController.cs b/src/Icons/Controllers/IconsController.cs index c17d174ce..96d763736 100644 --- a/src/Icons/Controllers/IconsController.cs +++ b/src/Icons/Controllers/IconsController.cs @@ -26,20 +26,16 @@ namespace Bit.Icons.Controllers _iconsSettings = iconsSettings; } - [HttpGet("")] - [ResponseCache(Duration = 86400 /*24 hours*/, VaryByQueryKeys = new string[] { "url" })] - public async Task Get([FromQuery]string url) + [HttpGet("{hostname}/icon.png")] + [ResponseCache(Duration = 86400 /*24 hours*/)] + public async Task Get(string hostname) { - if(string.IsNullOrWhiteSpace(url)) + if(string.IsNullOrWhiteSpace(hostname) || !hostname.Contains(".")) { return new BadRequestResult(); } - if(!url.StartsWith("http://") && !url.StartsWith("https://")) - { - url = "http://" + url; - } - + var url = $"http://{hostname}"; if(!Uri.TryCreate(url, UriKind.Absolute, out Uri uri)) { return new BadRequestResult();