eBooru/app/logical/custom_css.rb
Earlopain fc7d84affd
[RuboCop] Enable Style/FrozenStringLiteralComment
This reduces allocations on the posts page by about 5%, from basic testing
2024-02-25 18:15:55 +01:00

14 lines
310 B
Ruby

# frozen_string_literal: true
module CustomCss
def self.parse(css)
css.to_s.split(/\r\n|\r|\n/).map do |line|
if line =~ /\A@import/
line
else
line.gsub(/([^[:space:]])[[:space:]]*(?:!important)?[[:space:]]*(;|})/, "\\1 !important\\2")
end
end.join("\n")
end
end