1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-29 13:25:17 +01:00

use png extension for CDN caching

This commit is contained in:
Kyle Spearrin 2017-10-12 10:00:44 -04:00
parent ac901716cf
commit 4c3c594603

View File

@ -26,20 +26,16 @@ namespace Bit.Icons.Controllers
_iconsSettings = iconsSettings; _iconsSettings = iconsSettings;
} }
[HttpGet("")] [HttpGet("{hostname}/icon.png")]
[ResponseCache(Duration = 86400 /*24 hours*/, VaryByQueryKeys = new string[] { "url" })] [ResponseCache(Duration = 86400 /*24 hours*/)]
public async Task<IActionResult> Get([FromQuery]string url) public async Task<IActionResult> Get(string hostname)
{ {
if(string.IsNullOrWhiteSpace(url)) if(string.IsNullOrWhiteSpace(hostname) || !hostname.Contains("."))
{ {
return new BadRequestResult(); return new BadRequestResult();
} }
if(!url.StartsWith("http://") && !url.StartsWith("https://")) var url = $"http://{hostname}";
{
url = "http://" + url;
}
if(!Uri.TryCreate(url, UriKind.Absolute, out Uri uri)) if(!Uri.TryCreate(url, UriKind.Absolute, out Uri uri))
{ {
return new BadRequestResult(); return new BadRequestResult();