FIX: handle german quotes in discourse local-dates (#8386)

https://meta.discourse.org/t/insert-date-timezone-is-always-utc-my-timezone-is-ignored/126307
This commit is contained in:
Joffrey JAFFEUX 2019-11-21 11:43:35 +01:00 committed by GitHub
parent 026832fb80
commit 3d1b6b6729
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View File

@ -13,10 +13,12 @@ function addLocalDate(buffer, matches, state) {
countdown: null countdown: null
}; };
const matchString = matches[1].replace(/„|“/g, '"');
let parsed = parseBBCodeTag( let parsed = parseBBCodeTag(
"[date date" + matches[1] + "]", "[date date" + matchString + "]",
0, 0,
matches[1].length + 11 matchString.length + 11
); );
config.date = parsed.attrs.date; config.date = parsed.attrs.date;

View File

@ -80,4 +80,13 @@ describe PrettyText do
expect(excerpt).to eq("Wednesday, October 16, 2019 6:00 PM (UTC)") expect(excerpt).to eq("Wednesday, October 16, 2019 6:00 PM (UTC)")
end end
end end
context 'german quotes' do
let(:post) { Fabricate(:post, raw: '[date=2019-10-16 time=14:00:00 format="LLLL" timezone=„America/New_York“]') }
it 'converts german quotes to regular quotes' do
excerpt = PrettyText.excerpt(post.cooked, 200)
expect(excerpt).to eq('Wednesday, October 16, 2019 6:00 PM (UTC)')
end
end
end end