Skip to content

Commit

Permalink
Strip unicode nbsp.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefansundin committed Feb 24, 2016
1 parent a79b9da commit 793636f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions config/initializers/05-string.rb
Expand Up @@ -6,4 +6,9 @@ def to_line
def esc
self.gsub("&","&amp;").gsub("<","&lt;")
end

def ustrip
# remove extra unicode crap
self.gsub(/[\u00a0\u3000]/,"").strip
end
end
4 changes: 2 additions & 2 deletions views/facebook_feed.erb
Expand Up @@ -17,9 +17,9 @@ elsif post["type"] == "link"
"Link: #{post["link"].esc}"
elsif post["type"] == "event"
"Event: #{post["name"].esc}"
elsif post["description"]
elsif post["description"] and post["description"].ustrip != ""
post["description"].to_line.truncate(120).esc
elsif post["name"]
elsif post["name"] and post["name"].ustrip != ""
post["name"].to_line.esc
elsif post["type"]
post["type"].camelize
Expand Down

0 comments on commit 793636f

Please sign in to comment.