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
1d884efe
Unverified
Commit
1d884efe
authored
Apr 22, 2018
by
Tim Neutkens
Committed by
GitHub
Apr 22, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix url prop override (#4191)
* Fix url prop override * Remove console.log
parent
a691dd06
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
1 deletion
+42
-1
app.js
lib/app.js
+1
-1
url-prop-override.js
test/integration/basic/pages/url-prop-override.js
+16
-0
url-prop.js
test/integration/basic/pages/url-prop.js
+7
-0
index.test.js
test/integration/basic/test/index.test.js
+2
-0
rendering.js
test/integration/basic/test/rendering.js
+16
-0
No files found.
lib/app.js
View file @
1d884efe
...
@@ -45,7 +45,7 @@ export default class App extends Component {
...
@@ -45,7 +45,7 @@ export default class App extends Component {
const
{
router
,
Component
,
pageProps
}
=
this
.
props
const
{
router
,
Component
,
pageProps
}
=
this
.
props
const
url
=
createUrl
(
router
)
const
url
=
createUrl
(
router
)
return
<
Container
>
return
<
Container
>
<
Component
url
=
{
url
}
{...
pageProps
}
/
>
<
Component
{...
pageProps
}
url
=
{
url
}
/
>
<
/Container
>
<
/Container
>
}
}
}
}
...
...
test/integration/basic/pages/url-prop-override.js
0 → 100644
View file @
1d884efe
import
React
from
'react'
export
default
class
extends
React
.
Component
{
static
getInitialProps
()
{
return
{
url
:
'test'
// This gets overridden by Next in lib/_app.js
}
}
render
()
{
const
{
url
}
=
this
.
props
return
<
div
>
<
p
id
=
'pathname'
>
{
url
.
pathname
}
<
/p
>
<
p
id
=
'query'
>
{
Object
.
keys
(
url
.
query
).
length
}
<
/p
>
<
p
id
=
'aspath'
>
{
url
.
asPath
}
<
/p
>
<
/div
>
}
}
test/integration/basic/pages/url-prop.js
0 → 100644
View file @
1d884efe
export
default
({
url
})
=>
{
return
<
div
>
<
p
id
=
'pathname'
>
{
url
.
pathname
}
<
/p
>
<
p
id
=
'query'
>
{
Object
.
keys
(
url
.
query
).
length
}
<
/p
>
<
p
id
=
'aspath'
>
{
url
.
asPath
}
<
/p
>
<
/div
>
}
test/integration/basic/test/index.test.js
View file @
1d884efe
...
@@ -40,6 +40,8 @@ describe('Basic Features', () => {
...
@@ -40,6 +40,8 @@ describe('Basic Features', () => {
renderViaHTTP
(
context
.
appPort
,
'/custom-extension'
),
renderViaHTTP
(
context
.
appPort
,
'/custom-extension'
),
renderViaHTTP
(
context
.
appPort
,
'/styled-jsx'
),
renderViaHTTP
(
context
.
appPort
,
'/styled-jsx'
),
renderViaHTTP
(
context
.
appPort
,
'/with-cdm'
),
renderViaHTTP
(
context
.
appPort
,
'/with-cdm'
),
renderViaHTTP
(
context
.
appPort
,
'/url-prop'
),
renderViaHTTP
(
context
.
appPort
,
'/url-prop-override'
),
renderViaHTTP
(
context
.
appPort
,
'/nav'
),
renderViaHTTP
(
context
.
appPort
,
'/nav'
),
renderViaHTTP
(
context
.
appPort
,
'/nav/about'
),
renderViaHTTP
(
context
.
appPort
,
'/nav/about'
),
...
...
test/integration/basic/test/rendering.js
View file @
1d884efe
...
@@ -119,6 +119,22 @@ export default function ({ app }, suiteName, render, fetch) {
...
@@ -119,6 +119,22 @@ export default function ({ app }, suiteName, render, fetch) {
expect
(
$
(
'.as-path-content'
).
text
()).
toBe
(
'/nav/as-path?aa=10'
)
expect
(
$
(
'.as-path-content'
).
text
()).
toBe
(
'/nav/as-path?aa=10'
)
})
})
describe
(
'Url prop'
,
()
=>
{
it
(
'should provide pathname, query and asPath'
,
async
()
=>
{
const
$
=
await
get
$
(
'/url-prop'
)
expect
(
$
(
'#pathname'
).
text
()).
toBe
(
'/url-prop'
)
expect
(
$
(
'#query'
).
text
()).
toBe
(
'0'
)
expect
(
$
(
'#aspath'
).
text
()).
toBe
(
'/url-prop'
)
})
it
(
'should override props.url, even when getInitialProps returns url as property'
,
async
()
=>
{
const
$
=
await
get
$
(
'/url-prop-override'
)
expect
(
$
(
'#pathname'
).
text
()).
toBe
(
'/url-prop-override'
)
expect
(
$
(
'#query'
).
text
()).
toBe
(
'0'
)
expect
(
$
(
'#aspath'
).
text
()).
toBe
(
'/url-prop-override'
)
})
})
describe
(
'404'
,
()
=>
{
describe
(
'404'
,
()
=>
{
it
(
'should 404 on not existent page'
,
async
()
=>
{
it
(
'should 404 on not existent page'
,
async
()
=>
{
const
$
=
await
get
$
(
'/non-existent'
)
const
$
=
await
get
$
(
'/non-existent'
)
...
...
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