Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: linked messages containing slash symbol #1381

Merged
merged 1 commit into from
Sep 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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)
})
})
})