unicode fix in tags
This commit is contained in:
parent
8a2dd36b7e
commit
6855447204
2 changed files with 5 additions and 5 deletions
|
|
@ -36,7 +36,7 @@ module Diaspora
|
||||||
|
|
||||||
def format_tags(text, opts={})
|
def format_tags(text, opts={})
|
||||||
return text if opts[:plain_text]
|
return text if opts[:plain_text]
|
||||||
regex = /(^|\s)#([a-zA-Z0-9\-]+)/
|
regex = /(^|\s)#(\w+)/
|
||||||
form_message = text.gsub(regex) do |matched_string|
|
form_message = text.gsub(regex) do |matched_string|
|
||||||
"#{$~[1]}<a href=\"/tags/#{$~[2]}\" class=\"tag\">##{$~[2]}</a>"
|
"#{$~[1]}<a href=\"/tags/#{$~[2]}\" class=\"tag\">##{$~[2]}</a>"
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -13,13 +13,13 @@ describe Diaspora::Taggable do
|
||||||
|
|
||||||
describe '#format_tags' do
|
describe '#format_tags' do
|
||||||
before do
|
before do
|
||||||
@str = '#what #hey'
|
@str = '#what #hey #vöglein'
|
||||||
@object.send(@object.class.field_with_tags_setter, @str)
|
@object.send(@object.class.field_with_tags_setter, @str)
|
||||||
@object.build_tags
|
@object.build_tags
|
||||||
@object.save!
|
@object.save!
|
||||||
end
|
end
|
||||||
it 'links the tag to /p' do
|
it 'links the tag to /p' do
|
||||||
link = link_to('#what', '/tags/what', :class => 'tag')
|
link = link_to('#vöglein', '/tags/vöglein', :class => 'tag')
|
||||||
@object.format_tags(@str).should include(link)
|
@object.format_tags(@str).should include(link)
|
||||||
end
|
end
|
||||||
it 'responds to plain_text' do
|
it 'responds to plain_text' do
|
||||||
|
|
@ -38,8 +38,8 @@ describe Diaspora::Taggable do
|
||||||
end
|
end
|
||||||
describe '#tag_strings' do
|
describe '#tag_strings' do
|
||||||
it 'returns a string for every #thing' do
|
it 'returns a string for every #thing' do
|
||||||
str = '#what #hey #that"smybike. #@hey ##boo # #THATWASMYBIKE #hey#there #135440we #abc/23 ###'
|
str = '#what #hey #that"smybike. #@hey ##boo # #THATWASMYBIKE #vöglein #hey#there #135440we #abc/23 ###'
|
||||||
arr = ['what', 'hey', 'that', 'THATWASMYBIKE', '135440we', 'abc']
|
arr = ['what', 'hey', 'that', 'THATWASMYBIKE', 'vöglein', '135440we', 'abc']
|
||||||
|
|
||||||
@object.send(@object.class.field_with_tags_setter, str)
|
@object.send(@object.class.field_with_tags_setter, str)
|
||||||
@object.tag_strings.should =~ arr
|
@object.tag_strings.should =~ arr
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue