File tree Expand file tree Collapse file tree 3 files changed +44
-4
lines changed
development-runtime/cypress/integration/navigation
production-runtime/cypress/integration
packages/gatsby/cache-dir Expand file tree Collapse file tree 3 files changed +44
-4
lines changed Original file line number Diff line number Diff line change @@ -90,5 +90,26 @@ describe(`navigation`, () => {
90
90
. invoke ( `text` )
91
91
. should ( `equal` , `Hi from the second page` )
92
92
} )
93
+
94
+ it ( `should show 404 page when url with unicode characters point to a non-existent page route when navigating directly` , ( ) => {
95
+ cy . visit ( `/안녕404/` , {
96
+ failOnStatusCode : false ,
97
+ } ) . waitForRouteChange ( )
98
+
99
+ cy . get ( `h1` )
100
+ . invoke ( `text` )
101
+ . should ( `eq` , `Gatsby.js development 404 page` )
102
+ } )
103
+
104
+ it ( `should show 404 page when url with unicode characters point to a non-existent page route when navigating on client` , ( ) => {
105
+ cy . visit ( `/` ) . waitForRouteChange ( )
106
+ cy . window ( )
107
+ . then ( win => win . ___navigate ( `/안녕404/` ) )
108
+ . waitForRouteChange ( )
109
+
110
+ cy . get ( `h1` )
111
+ . invoke ( `text` )
112
+ . should ( `eq` , `Gatsby.js development 404 page` )
113
+ } )
93
114
} )
94
115
} )
Original file line number Diff line number Diff line change @@ -131,5 +131,22 @@ describe(`Production build tests`, () => {
131
131
. invoke ( `text` )
132
132
. should ( `equal` , `Hi from the second page` )
133
133
} )
134
+
135
+ it ( `should show 404 page when url with unicode characters point to a non-existent page route when navigating directly` , ( ) => {
136
+ cy . visit ( `/안녕404/` , {
137
+ failOnStatusCode : false ,
138
+ } ) . waitForRouteChange ( )
139
+
140
+ cy . getTestElement ( `404` ) . should ( `exist` )
141
+ } )
142
+
143
+ it ( `should show 404 page when url with unicode characters point to a non-existent page route when navigating on client` , ( ) => {
144
+ cy . visit ( `/` ) . waitForRouteChange ( )
145
+ cy . window ( )
146
+ . then ( win => win . ___navigate ( `/안녕404/` ) )
147
+ . waitForRouteChange ( )
148
+
149
+ cy . getTestElement ( `404` ) . should ( `exist` )
150
+ } )
134
151
} )
135
152
} )
Original file line number Diff line number Diff line change @@ -72,12 +72,14 @@ apiRunnerAsync(`onClientEntry`).then(() => {
72
72
id = "gatsby-focus-wrapper"
73
73
>
74
74
< RouteHandler
75
- path = { encodeURI (
75
+ path = {
76
76
pageResources . page . path === `/404.html`
77
77
? stripPrefix ( location . pathname , __BASE_PATH__ )
78
- : pageResources . page . matchPath ||
79
- pageResources . page . path
80
- ) }
78
+ : encodeURI (
79
+ pageResources . page . matchPath ||
80
+ pageResources . page . path
81
+ )
82
+ }
81
83
{ ...this . props }
82
84
location = { location }
83
85
pageResources = { pageResources }
You can’t perform that action at this time.
0 commit comments