From 8852e4dc20db420e7e012b3265cbf4d369a761ba Mon Sep 17 00:00:00 2001 From: Ben Cates Date: Mon, 31 Dec 2012 15:30:35 -0500 Subject: [PATCH] Replace ugly regex with POSIX class `[[:space:]]` works like `\s` in regexes, except it is encoding aware. --- lib/capybara/helpers.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/capybara/helpers.rb b/lib/capybara/helpers.rb index 7b9c1335..9d1e83cb 100644 --- a/lib/capybara/helpers.rb +++ b/lib/capybara/helpers.rb @@ -13,10 +13,7 @@ module Capybara # @return [String] Normalized text # def normalize_whitespace(text) - # http://en.wikipedia.org/wiki/Whitespace_character#Unicode - # We should have a better reference. - # See also http://stackoverflow.com/a/11758133/525872 - text.to_s.gsub(/[\s\u0085\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000]+/, ' ').strip + text.to_s.gsub(/[[:space:]]+/, ' ').strip end ##