Skip to content

Commit

Permalink
fix: linked messages containing slash symbol (#1381)
Browse files Browse the repository at this point in the history
  • Loading branch information
nabebin committed Sep 13, 2021
1 parent f112292 commit 6380328
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import I18nPath from './path'
import type { PathValue } from './path'

const htmlTagMatcher = /<\/?[\w\s="/.':;#-\/]+>/
const linkKeyMatcher = /(?:@(?:\.[a-z]+)?:(?:[\w\-_|.]+|\([\w\-_|.]+\)))/g
const linkKeyMatcher = /(?:@(?:\.[a-z]+)?:(?:[\w\-_|./]+|\([\w\-_|./]+\)))/g
const linkKeyPrefixMatcher = /^@(?:\.([a-z]+))?:/
const bracketsMatcher = /[()]/g
const defaultModifiers = {
Expand Down
23 changes: 23 additions & 0 deletions test/unit/issues.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -790,4 +790,27 @@ describe('issues', () => {
.catch(console.error)
})
})

describe('#1380', () => {
it('should be translated', done => {
vm = new Vue({
i18n: new VueI18n({
locale: 'en',
messages: {
en: {
'link-with-slash': '@:key/with/slash',
'key/with/slash': 'should be translated'
}
}
}),
render (h) {
return h('div',
[ h('p', { ref: 'text' }, [this.$t('link-with-slash')]) ])
}
}).$mount()
Vue.nextTick().then(() => {
assert.strictEqual(vm.$refs.text.textContent, 'should be translated')
}).then(done)
})
})
})

0 comments on commit 6380328

Please sign in to comment.