mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 16:34:31 +08:00
DEV: Prefer \A and \z over ^ and $ in regexes (#19936)
This commit is contained in:

committed by
GitHub

parent
f7907a3645
commit
666536cbd1
@ -386,7 +386,7 @@ class UploadCreator
|
||||
end
|
||||
|
||||
def convert_heif_to_jpeg?
|
||||
File.extname(@filename).downcase.match?(/\.hei(f|c)$/)
|
||||
File.extname(@filename).downcase.match?(/\.hei(f|c)\z/)
|
||||
end
|
||||
|
||||
def convert_heif!
|
||||
@ -593,7 +593,7 @@ class UploadCreator
|
||||
def should_optimize?
|
||||
# GIF is too slow (plus, we'll soon be converting them to MP4)
|
||||
# Optimizing SVG is useless
|
||||
return false if @file.path =~ /\.(gif|svg)$/i
|
||||
return false if @file.path =~ /\.(gif|svg)\z/i
|
||||
# Safeguard for large PNGs
|
||||
return pixels < 2_000_000 if @file.path =~ /\.png/i
|
||||
# Everything else is fine!
|
||||
|
Reference in New Issue
Block a user