Skip to content

Commit e17e533

Browse files
authored
fix(gatsby): fix DSG special char 404 issue (#35336)
1 parent bb3287e commit e17e533

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

e2e-tests/production-runtime/cypress/integration/1-production.js

+15
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,21 @@ describe(`Production build tests`, () => {
131131
})
132132

133133
describe(`Supports unicode characters in urls`, () => {
134+
describe(`DSG pages`, () => {
135+
it(`Can navigate directly`, () => {
136+
cy.visit(encodeURI(`/한글-URL`)).waitForRouteChange()
137+
cy.getTestElement(`dom-marker`).contains("page-2")
138+
})
139+
140+
it(`Can navigate on client`, () => {
141+
cy.visit(`/`).waitForRouteChange()
142+
cy.getTestElement(`dsg-page-with-unicode-path`)
143+
.click()
144+
.waitForRouteChange()
145+
cy.getTestElement(`dom-marker`).contains("page-2")
146+
})
147+
})
148+
134149
it(`Can navigate directly`, () => {
135150
cy.visit(encodeURI(`/안녕/`), {
136151
// Cypress seems to think it's 404

e2e-tests/production-runtime/gatsby-node.js

+6
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ exports.createPages = ({ actions: { createPage, createRedirect } }) => {
105105
component: path.resolve(`src/pages/page-2.js`),
106106
})
107107

108+
createPage({
109+
path: `/한글-URL`,
110+
component: path.resolve(`src/pages/page-2.js`),
111+
defer: true,
112+
})
113+
108114
createPage({
109115
path: `/foo/@something/bar`,
110116
component: path.resolve(`src/pages/page-2.js`),

e2e-tests/production-runtime/src/pages/index.js

+5
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ const IndexPage = ({ pageContext }) => (
6161
Go to page with unicode path
6262
</Link>
6363
</li>
64+
<li>
65+
<Link to="/한글-URL" data-testid="dsg-page-with-unicode-path">
66+
Go to DSG page with unicode path
67+
</Link>
68+
</li>
6469
<li>
6570
<Link to="/foo/@something/bar" data-testid="page-with-encodable-path">
6671
Go to page with unicode path

packages/gatsby/src/utils/find-page-by-path.ts

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ export function findPageByPath(
4747
): IGatsbyPage | undefined {
4848
const { pages } = state
4949

50+
path = decodeURIComponent(path)
51+
5052
// first check by exact path
5153
let page = pages.get(path)
5254
if (page) {

0 commit comments

Comments
 (0)