Skip to content

Commit

Permalink
🐛 bug(format): fix cannot collectly parse percent
Browse files Browse the repository at this point in the history
close #191
  • Loading branch information
kazupon committed Jul 8, 2017
1 parent 93e4ece commit fc71eda
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ export function parse (format: string): Array<Token> {
tokens.push({ value: sub, type })
} else if (char === '%') {
// when found rails i18n syntax, skip text capture
if (format[(position)] !== '{') {
text += char
}
} else {
text += char
}
Expand Down
12 changes: 12 additions & 0 deletions test/unit/issues.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import messages from './fixture/index'
import { parse } from '../../src/format'

describe('issues', () => {
let vm, i18n
Expand Down Expand Up @@ -241,4 +242,15 @@ describe('issues', () => {
}).then(done)
})
})

describe('#191', () => {
it('should be parsed', () => {
const tokens = parse('{deposit}% PREPAYMENT')
assert(tokens.length === 2)
assert.equal(tokens[0].type, 'named')
assert.equal(tokens[0].value, 'deposit')
assert.equal(tokens[1].type, 'text')
assert.equal(tokens[1].value, '% PREPAYMENT')
})
})
})

0 comments on commit fc71eda

Please sign in to comment.