mirror of
https://github.com/sdsykes/fastimage.git
synced 2025-10-18 00:00:52 -04:00
Improve parse_type UnknownImageType detection
In case of 'ice' file type when neither 1 or 2 is found it should raise ```UnknownImageType``` but it didn't, probably due to the method not being 100% DRY. This commit fixes both issues at once
This commit is contained in:
parent
c99b127d1b
commit
13b0244968
@ -442,7 +442,7 @@ class FastImage
|
||||
end
|
||||
|
||||
def parse_type
|
||||
case @stream.peek(2)
|
||||
parsed_type = case @stream.peek(2)
|
||||
when "BM"
|
||||
:bmp
|
||||
when "GI"
|
||||
@ -462,22 +462,14 @@ class FastImage
|
||||
when 2 then :cur
|
||||
end
|
||||
when "RI"
|
||||
if @stream.peek(12)[8..11] == "WEBP"
|
||||
:webp
|
||||
else
|
||||
raise UnknownImageType
|
||||
end
|
||||
:webp if @stream.peek(12)[8..11] == "WEBP"
|
||||
when "<s"
|
||||
:svg
|
||||
when "<?"
|
||||
if @stream.peek(100).include?("<svg")
|
||||
:svg
|
||||
else
|
||||
raise UnknownImageType
|
||||
end
|
||||
else
|
||||
raise UnknownImageType
|
||||
:svg if @stream.peek(100).include?("<svg")
|
||||
end
|
||||
|
||||
parsed_type or raise UnknownImageType
|
||||
end
|
||||
|
||||
def parse_size_for_ico
|
||||
|
Loading…
x
Reference in New Issue
Block a user