Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/helpers/colors_helper.rb')
-rw-r--r--app/helpers/colors_helper.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/app/helpers/colors_helper.rb b/app/helpers/colors_helper.rb
index bc72122220a..80cf6f197e5 100644
--- a/app/helpers/colors_helper.rb
+++ b/app/helpers/colors_helper.rb
@@ -4,7 +4,9 @@ module ColorsHelper
HEX_COLOR_PATTERN = /\A\#(?:[0-9A-Fa-f]{3}){1,2}\Z/.freeze
def hex_color_to_rgb_array(hex_color)
- raise ArgumentError, "invalid hex color `#{hex_color}`" unless hex_color =~ HEX_COLOR_PATTERN
+ unless hex_color.is_a?(String) && HEX_COLOR_PATTERN.match?(hex_color)
+ raise ArgumentError, "invalid hex color `#{hex_color}`"
+ end
hex_color.length == 7 ? hex_color[1, 7].scan(/.{2}/).map(&:hex) : hex_color[1, 4].scan(/./).map { |v| (v * 2).hex }
end