Sha256: add7d9fc4c228788a6f5492c6a6ea12acc3952e792e0bfe667aa99ed6ff1e071
Contents?: true
Size: 1.01 KB
Versions: 12
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.to_s 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
12 entries across 12 versions & 1 rubygems