From 5cfb43bebf498f970b5be0b7f4b1a59b28d3bb43 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 5 Oct 2018 09:13:57 -0400 Subject: [PATCH] webp support --- src/Icons/Services/IconFetchingService.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Icons/Services/IconFetchingService.cs b/src/Icons/Services/IconFetchingService.cs index 482d1abe0..ed1cc0cb3 100644 --- a/src/Icons/Services/IconFetchingService.cs +++ b/src/Icons/Services/IconFetchingService.cs @@ -9,6 +9,7 @@ using Bit.Icons.Models; using AngleSharp.Parser.Html; using Microsoft.Extensions.Logging; using System.Text.RegularExpressions; +using System.Text; namespace Bit.Icons.Services { @@ -21,6 +22,7 @@ namespace Bit.Icons.Services private readonly string _pngMediaType = "image/png"; private readonly byte[] _pngHeader = new byte[] { 137, 80, 78, 71 }; + private readonly byte[] _webpHeader = Encoding.UTF8.GetBytes("RIFF"); private readonly string _icoMediaType = "image/x-icon"; private readonly string _icoAltMediaType = "image/vnd.microsoft.icon"; @@ -246,7 +248,7 @@ namespace Bit.Icons.Services { format = _icoMediaType; } - else if(HeaderMatch(bytes, _pngHeader)) + else if(HeaderMatch(bytes, _pngHeader) || HeaderMatch(bytes, _webpHeader)) { format = _pngMediaType; }