mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 14:15:13 +00:00
Merge pull request #2269 from clarkdo/external_url
fix: redirect relative path issue and message refactoring
This commit is contained in:
commit
e2c0b17fb7
@ -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) {
|
||||||
|
@ -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,
|
||||||
|
@ -323,6 +323,7 @@ Options.defaults = {
|
|||||||
back_to_home: 'Back to the home page',
|
back_to_home: 'Back to the home page',
|
||||||
server_error_details: 'An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details.',
|
server_error_details: 'An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details.',
|
||||||
client_error: 'Error',
|
client_error: 'Error',
|
||||||
client_error_details: 'An error occurred while rendering the page. Check developer tools console for details.'
|
client_error_details: 'An error occurred while rendering the page. Check developer tools console for details.',
|
||||||
|
redirect: 'Redirecting to external page.'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 => {
|
||||||
|
Loading…
Reference in New Issue
Block a user