Skip to content

Commit

Permalink
Treat hash literal as valid keys
Browse files Browse the repository at this point in the history
  • Loading branch information
otoyo authored and glebm committed Nov 20, 2021
1 parent 3cfade5 commit 2faebce
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/i18n/tasks/scanners/ruby_key_literals.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def strip_literal(literal)
literal
end

VALID_KEY_CHARS = /(?:[[:word:]]|[-.?!:;À-ž\/])/.freeze
VALID_KEY_CHARS = /(?:[[:word:]]|[-.?!:;À-ž\/'"\[\]])/.freeze
VALID_KEY_RE = /^#{VALID_KEY_CHARS}+$/.freeze

def valid_key?(key)
Expand Down
13 changes: 11 additions & 2 deletions spec/scanners/ruby_key_literals_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,17 @@
end

describe '#valid_key?' do
it 'allows forward slash in key' do
expect(scanner).to be_valid_key('category/product')
subject { scanner }

context 'slash in key' do
let(:key) { 'category/product' }
it { is_expected.to be_valid_key(key) }
end

context 'hash in key' do
let(:key) { 'category/product' }
let(:key) { 'some_hash["some_key"]' }
it { is_expected.to be_valid_key(key) }
end
end
end

0 comments on commit 2faebce

Please sign in to comment.