Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
4026d9be
Unverified
Commit
4026d9be
authored
Oct 27, 2020
by
JJ Kasper
Committed by
GitHub
Oct 27, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unstable_ prefix from unstable_redirect (#18282)
parent
1b22a39e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
22 deletions
+23
-22
render.tsx
packages/next/next-server/server/render.tsx
+18
-17
index.d.ts
packages/next/types/index.d.ts
+2
-2
[post].js
test/integration/gssp-redirect/pages/gsp-blog/[post].js
+1
-1
[post].js
test/integration/gssp-redirect/pages/gssp-blog/[post].js
+1
-1
index.test.js
test/integration/gssp-redirect/test/index.test.js
+1
-1
No files found.
packages/next/next-server/server/render.tsx
View file @
4026d9be
...
@@ -624,7 +624,7 @@ export async function renderToHTML(
...
@@ -624,7 +624,7 @@ export async function renderToHTML(
(
key
)
=>
(
key
)
=>
key
!==
'revalidate'
&&
key
!==
'revalidate'
&&
key
!==
'props'
&&
key
!==
'props'
&&
key
!==
'
unstable_
redirect'
&&
key
!==
'redirect'
&&
key
!==
'unstable_notFound'
key
!==
'unstable_notFound'
)
)
...
@@ -649,11 +649,11 @@ export async function renderToHTML(
...
@@ -649,11 +649,11 @@ export async function renderToHTML(
}
}
if
(
if
(
'
unstable_
redirect'
in
data
&&
'redirect'
in
data
&&
data
.
unstable_
redirect
&&
data
.
redirect
&&
typeof
data
.
unstable_
redirect
===
'object'
typeof
data
.
redirect
===
'object'
)
{
)
{
checkRedirectValues
(
data
.
unstable_
redirect
,
req
)
checkRedirectValues
(
data
.
redirect
,
req
)
if
(
isBuildTimeSSG
)
{
if
(
isBuildTimeSSG
)
{
throw
new
Error
(
throw
new
Error
(
...
@@ -664,10 +664,10 @@ export async function renderToHTML(
...
@@ -664,10 +664,10 @@ export async function renderToHTML(
if
(
isDataReq
)
{
if
(
isDataReq
)
{
;(
data
as
any
).
props
=
{
;(
data
as
any
).
props
=
{
__N_REDIRECT
:
data
.
unstable_
redirect
.
destination
,
__N_REDIRECT
:
data
.
redirect
.
destination
,
}
}
}
else
{
}
else
{
handleRedirect
(
res
,
data
.
unstable_
redirect
)
handleRedirect
(
res
,
data
.
redirect
)
return
null
return
null
}
}
}
}
...
@@ -760,11 +760,15 @@ export async function renderToHTML(
...
@@ -760,11 +760,15 @@ export async function renderToHTML(
const
invalidKeys
=
Object
.
keys
(
data
).
filter
(
const
invalidKeys
=
Object
.
keys
(
data
).
filter
(
(
key
)
=>
(
key
)
=>
key
!==
'props'
&&
key
!==
'props'
&&
key
!==
'redirect'
&&
key
!==
'unstable_notFound'
key
!==
'unstable_redirect'
&&
key
!==
'unstable_notFound'
)
)
if
((
data
as
any
).
unstable_redirect
)
{
throw
new
Error
(
`unstable_redirect has been renamed to redirect, please update the field to continue. Page:
${
pathname
}
`
)
}
if
(
invalidKeys
.
length
)
{
if
(
invalidKeys
.
length
)
{
throw
new
Error
(
invalidKeysMsg
(
'getServerSideProps'
,
invalidKeys
))
throw
new
Error
(
invalidKeysMsg
(
'getServerSideProps'
,
invalidKeys
))
}
}
...
@@ -780,18 +784,15 @@ export async function renderToHTML(
...
@@ -780,18 +784,15 @@ export async function renderToHTML(
return
null
return
null
}
}
if
(
if
(
'redirect'
in
data
&&
typeof
data
.
redirect
===
'object'
)
{
'unstable_redirect'
in
data
&&
checkRedirectValues
(
data
.
redirect
,
req
)
typeof
data
.
unstable_redirect
===
'object'
)
{
checkRedirectValues
(
data
.
unstable_redirect
,
req
)
if
(
isDataReq
)
{
if
(
isDataReq
)
{
;(
data
as
any
).
props
=
{
;(
data
as
any
).
props
=
{
__N_REDIRECT
:
data
.
unstable_
redirect
.
destination
,
__N_REDIRECT
:
data
.
redirect
.
destination
,
}
}
}
else
{
}
else
{
handleRedirect
(
res
,
data
.
unstable_
redirect
)
handleRedirect
(
res
,
data
.
redirect
)
return
null
return
null
}
}
}
}
...
...
packages/next/types/index.d.ts
View file @
4026d9be
...
@@ -87,7 +87,7 @@ export type GetStaticPropsContext<Q extends ParsedUrlQuery = ParsedUrlQuery> = {
...
@@ -87,7 +87,7 @@ export type GetStaticPropsContext<Q extends ParsedUrlQuery = ParsedUrlQuery> = {
export
type
GetStaticPropsResult
<
P
>
=
export
type
GetStaticPropsResult
<
P
>
=
|
{
props
:
P
;
revalidate
?:
number
|
boolean
}
|
{
props
:
P
;
revalidate
?:
number
|
boolean
}
|
{
unstable_
redirect
:
Redirect
;
revalidate
?:
number
|
boolean
}
|
{
redirect
:
Redirect
;
revalidate
?:
number
|
boolean
}
|
{
unstable_notFound
:
true
}
|
{
unstable_notFound
:
true
}
export
type
GetStaticProps
<
export
type
GetStaticProps
<
...
@@ -132,7 +132,7 @@ export type GetServerSidePropsContext<
...
@@ -132,7 +132,7 @@ export type GetServerSidePropsContext<
export
type
GetServerSidePropsResult
<
P
>
=
export
type
GetServerSidePropsResult
<
P
>
=
|
{
props
:
P
}
|
{
props
:
P
}
|
{
unstable_
redirect
:
Redirect
}
|
{
redirect
:
Redirect
}
|
{
unstable_notFound
:
true
}
|
{
unstable_notFound
:
true
}
export
type
GetServerSideProps
<
export
type
GetServerSideProps
<
...
...
test/integration/gssp-redirect/pages/gsp-blog/[post].js
View file @
4026d9be
...
@@ -26,7 +26,7 @@ export const getStaticProps = ({ params }) => {
...
@@ -26,7 +26,7 @@ export const getStaticProps = ({ params }) => {
}
}
return
{
return
{
unstable_
redirect
:
{
redirect
:
{
destination
,
destination
,
permanent
:
params
.
post
.
includes
(
'permanent'
),
permanent
:
params
.
post
.
includes
(
'permanent'
),
},
},
...
...
test/integration/gssp-redirect/pages/gssp-blog/[post].js
View file @
4026d9be
...
@@ -16,7 +16,7 @@ export const getServerSideProps = ({ params }) => {
...
@@ -16,7 +16,7 @@ export const getServerSideProps = ({ params }) => {
}
}
return
{
return
{
unstable_
redirect
:
{
redirect
:
{
destination
,
destination
,
permanent
:
params
.
post
.
includes
(
'permanent'
),
permanent
:
params
.
post
.
includes
(
'permanent'
),
},
},
...
...
test/integration/gssp-redirect/test/index.test.js
View file @
4026d9be
...
@@ -320,7 +320,7 @@ describe('GS(S)P Redirect Support', () => {
...
@@ -320,7 +320,7 @@ describe('GS(S)P Redirect Support', () => {
export const getStaticProps = ({ params }) => {
export const getStaticProps = ({ params }) => {
return {
return {
unstable_
redirect: {
redirect: {
permanent: true,
permanent: true,
destination: '/another'
destination: '/another'
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment