Skip to content

Commit

Permalink
Fix replacing of  , aka   so it works on 1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
manveru committed Jun 7, 2009
1 parent 520081c commit 8d2c027
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/webrat/core/locators/link_locator.rb
Expand Up @@ -45,10 +45,14 @@ def link_elements
end

def replace_nbsp(str)
if str.respond_to?(:force_encoding)
str.force_encoding('UTF-8').gsub(/\xc2\xa0/u, ' ')
if str.respond_to?(:valid_encoding?)
if str.valid_encoding?
str.gsub(/\xc2\xa0/u, ' ')
else
str.force_encoding('UTF-8').gsub(/\xc2\xa0/u, ' ')
end
else
str.gsub("\xc2\xa0", ' ')
str.gsub(/\xc2\xa0/u, ' ')
end
end

Expand Down

0 comments on commit 8d2c027

Please sign in to comment.