mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Clear up resolve_link_as
Swaps to case/when to highlight the 3 branches better and uses `presence_in` to cut down on the else branch noise. `resolve_link_as` added in:eb90b8bc86
Most recent other commit:46bfd082b0
Made a decision to tweak this as core, don't send cosmetic PRs.
This commit is contained in:
parent
c7647f8842
commit
915b9cdbb7
1 changed files with 6 additions and 8 deletions
|
@ -530,14 +530,12 @@ module ActionView
|
||||||
end
|
end
|
||||||
|
|
||||||
def resolve_link_as(extname, mime_type)
|
def resolve_link_as(extname, mime_type)
|
||||||
if extname == "js"
|
case extname
|
||||||
"script"
|
when "js" then "script"
|
||||||
elsif extname == "css"
|
when "css" then "style"
|
||||||
"style"
|
when "vtt" then "track"
|
||||||
elsif extname == "vtt"
|
else
|
||||||
"track"
|
mime_type.to_s.split("/").first.presence_in(%w(audio video font image))
|
||||||
elsif (type = mime_type.to_s.split("/")[0]) && type.in?(%w(audio video font image))
|
|
||||||
type
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue