fix(dossier): tag can contain non breaking space
This commit is contained in:
parent
d7c5dcf8bb
commit
f2e8dba8e4
3 changed files with 11 additions and 2 deletions
|
@ -42,7 +42,7 @@ module TagsSubstitutionConcern
|
|||
|
||||
define_combinator :tag_text do
|
||||
join(single(tag_text_first_char) + many(tag_text_char)).fmap do |str|
|
||||
str.force_encoding('utf-8').encode
|
||||
str.force_encoding('utf-8').encode.gsub(/[[:space:]]/, ' ')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ class TypesDeChamp::TypeDeChampBase
|
|||
stable_id = self.stable_id
|
||||
[
|
||||
{
|
||||
libelle: libelle,
|
||||
libelle: libelle.gsub(/[[:space:]]/, ' '),
|
||||
id: "tdc#{stable_id}",
|
||||
description: description,
|
||||
lambda: -> (champs) {
|
||||
|
|
|
@ -519,5 +519,14 @@ describe TagsSubstitutionConcern, type: :model do
|
|||
{ tag: "numéro-du - dossier" }
|
||||
])
|
||||
end
|
||||
|
||||
it 'normalize white spaces' do
|
||||
tokens = TagsSubstitutionConcern::TagsParser.parse("hello --Jour(s) fixe(s)\xc2\xA0souhaité(s)\xc2\xA0:-- world".encode('utf-8'))
|
||||
expect(tokens).to eq([
|
||||
{ text: "hello " },
|
||||
{ tag: "Jour(s) fixe(s) souhaité(s) :" },
|
||||
{ text: " world" }
|
||||
])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue