Skip to content

Commit 915b9cd

Browse files
committed
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: eb90b8b Most recent other commit: 46bfd08 Made a decision to tweak this as core, don't send cosmetic PRs.
1 parent c7647f8 commit 915b9cd

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

actionview/lib/action_view/helpers/asset_tag_helper.rb

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -530,14 +530,12 @@ def check_for_image_tag_errors(options)
530530
end
531531

532532
def resolve_link_as(extname, mime_type)
533-
if extname == "js"
534-
"script"
535-
elsif extname == "css"
536-
"style"
537-
elsif extname == "vtt"
538-
"track"
539-
elsif (type = mime_type.to_s.split("/")[0]) && type.in?(%w(audio video font image))
540-
type
533+
case extname
534+
when "js" then "script"
535+
when "css" then "style"
536+
when "vtt" then "track"
537+
else
538+
mime_type.to_s.split("/").first.presence_in(%w(audio video font image))
541539
end
542540
end
543541

0 commit comments

Comments
 (0)