266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
|
# File 'spaceship/lib/spaceship/two_step_or_factor_client.rb', line 266
def match_phone_to_masked_phone(phone_number, masked_number)
characters_to_remove_from_phone_numbers = ' \-()"'
phone_number = phone_number.tr(characters_to_remove_from_phone_numbers, '')
number_with_dialcode_masked = masked_number.tr(characters_to_remove_from_phone_numbers, '')
maskings_count = number_with_dialcode_masked.count('•') pattern = /^([0-9+]{2,4})([•]{#{maskings_count}})([0-9]{2})$/
replacement = "\\1([0-9]{#{maskings_count - 2},#{maskings_count}})\\3"
number_with_dialcode_regex_part = number_with_dialcode_masked.gsub(pattern, replacement)
backslash = '\\'
number_with_dialcode_regex_part = backslash + number_with_dialcode_regex_part
number_with_dialcode_regex = /^#{number_with_dialcode_regex_part}$/
return phone_number =~ number_with_dialcode_regex
end
|