Sha256: 500f8e56da6f92d426d274a6701e97c019cd58041807c057cc8587e2e18acf5b
Contents?: true
Size: 1.01 KB
Versions: 5
Compression:
Stored size: 1.01 KB
Contents
require "mem" module Mihari module Mixins module DisallowedDataValue include Mem # # Normalize a value as a disallowed data value # # @param [String] value Data value # # @return [String, Regexp] Normalized value # def normalize_disallowed_data_value(value) return value if !value.start_with?("/") || !value.end_with?("/") # if a value is surrounded by slashes, take it as a regexp value_without_slashes = value[1..-2] Regexp.compile value_without_slashes end memoize :normalize_disallowed_data_value # # Check whetehr a value is valid format as a disallowed data value # # @param [String] value Data value # # @return [Boolean] true if it is valid, otherwise false # def valid_disallowed_data_value?(value) begin normalize_disallowed_data_value value rescue RegexpError return false end true end end end end
Version data entries
5 entries across 5 versions & 1 rubygems