refactor: move redirect message to option.messges

This commit is contained in:
Clark Du 2017-11-28 22:05:17 +08:00
parent 97eaa1b671
commit 40b9d23ea9
No known key found for this signature in database
GPG Key ID: D0E5986AF78B86D9
3 changed files with 4 additions and 3 deletions

View File

@ -8,7 +8,7 @@ export default {
props: ['nuxtChildKey'], props: ['nuxtChildKey'],
render(h) { render(h) {
if (this.nuxt._redirected) { if (this.nuxt._redirected) {
return h('div', [ 'redirecting.' ]) return h('div', [ '<%= messages.redirect %>' ])
} }
// If there is some error // If there is some error
if (this.nuxt.err) { if (this.nuxt.err) {

View File

@ -132,7 +132,8 @@ export async function setContext(app, context) {
path = status path = status
status = 302 status = 302
} }
if (path.charAt(0) === '/' && path.charAt(1) !== '/') { // "/absolute/route", "./relative/route" or "../relative/route"
if (/(^[.]{1,2}\/)|(^\/(?!\/))/.test(path)) {
app.context.next({ app.context.next({
path: path, path: path,
query: query, query: query,

View File

@ -127,7 +127,7 @@ test('/redirect -> external link', async t => {
} }
}) })
t.is(headers.Location, 'https://nuxtjs.org') t.is(headers.Location, 'https://nuxtjs.org')
t.true(html.includes('<div>redirecting.</div>')) t.true(html.includes('<div>Redirecting to external page.</div>'))
}) })
test('/special-state -> check window.__NUXT__.test = true', async t => { test('/special-state -> check window.__NUXT__.test = true', async t => {