-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gatsby): ignore case option in create redirect (#29742)
* Add ignoreCase option for createRedirect and support it in client side navigation * Add typings for ignoreCase * Update packages/gatsby/src/redux/actions/public.js Co-authored-by: Michal Piechowiak <[email protected]> * Prepare lowercased redirects at build time * Add tests * Remove only * Switch to O(1) Maps * Update navigate as well * Update packages/gatsby/index.d.ts Co-authored-by: Ward Peeters <[email protected]> * Update packages/gatsby/cache-dir/navigation.js Co-authored-by: Ward Peeters <[email protected]> * Set ignoreCase to false by default * Update snapshot * toLowerCase not toLowercase fml Co-authored-by: Michal Piechowiak <[email protected]> Co-authored-by: Ward Peeters <[email protected]>
- Loading branch information
1 parent
662fe41
commit 91b9d66
Showing
9 changed files
with
88 additions
and
60 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
e2e-tests/production-runtime/cypress/integration/redirects.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
describe(`Redirects`, () => { | ||
it(`are case insensitive when ignoreCase is set to true`, () => { | ||
cy.visit(`/Longue-PAGE`, { failOnStatusCode: false }).waitForRouteChange() | ||
|
||
cy.get(`h1`).invoke(`text`).should(`contain`, `Hi from the long page`) | ||
}) | ||
it(`are case sensitive when ignoreCase is set to false`, () => { | ||
cy.visit(`/PAGINA-larga`, { failOnStatusCode: false }).waitForRouteChange() | ||
|
||
cy.get(`h1`).invoke(`text`).should(`contain`, `NOT FOUND`) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ exports[`Add redirects allows you to add redirects 1`] = ` | |
Object { | ||
"payload": Object { | ||
"fromPath": "/old/hello-world", | ||
"ignoreCase": false, | ||
"isPermanent": false, | ||
"redirectInBrowser": false, | ||
"toPath": "/new/hello-world", | ||
|
@@ -16,6 +17,7 @@ exports[`Add redirects create redirects as permanent 1`] = ` | |
Object { | ||
"payload": Object { | ||
"fromPath": "/old/hello-world", | ||
"ignoreCase": false, | ||
"isPermanent": true, | ||
"redirectInBrowser": false, | ||
"toPath": "/new/hello-world", | ||
|
@@ -28,6 +30,7 @@ exports[`Add redirects creates redirects from the URL starts with // 1`] = ` | |
Object { | ||
"payload": Object { | ||
"fromPath": "//example.com", | ||
"ignoreCase": false, | ||
"isPermanent": false, | ||
"redirectInBrowser": false, | ||
"toPath": "/new/hello-world-2", | ||
|
@@ -40,6 +43,7 @@ exports[`Add redirects creates redirects from the URL starts with ftp 1`] = ` | |
Object { | ||
"payload": Object { | ||
"fromPath": "ftp://example.com", | ||
"ignoreCase": false, | ||
"isPermanent": false, | ||
"redirectInBrowser": false, | ||
"toPath": "/new/hello-world-3", | ||
|
@@ -52,6 +56,7 @@ exports[`Add redirects creates redirects from the URL starts with http 1`] = ` | |
Object { | ||
"payload": Object { | ||
"fromPath": "http://example.com", | ||
"ignoreCase": false, | ||
"isPermanent": false, | ||
"redirectInBrowser": false, | ||
"toPath": "/new/hello-world-1", | ||
|
@@ -64,6 +69,7 @@ exports[`Add redirects creates redirects from the URL starts with https 1`] = ` | |
Object { | ||
"payload": Object { | ||
"fromPath": "https://example.com", | ||
"ignoreCase": false, | ||
"isPermanent": false, | ||
"redirectInBrowser": false, | ||
"toPath": "/new/hello-world-0", | ||
|
@@ -76,6 +82,7 @@ exports[`Add redirects creates redirects from the URL starts with mailto 1`] = ` | |
Object { | ||
"payload": Object { | ||
"fromPath": "mailto:[email protected]", | ||
"ignoreCase": false, | ||
"isPermanent": false, | ||
"redirectInBrowser": false, | ||
"toPath": "/new/hello-world-4", | ||
|
@@ -88,6 +95,7 @@ exports[`Add redirects creates redirects to the URL starts with // 1`] = ` | |
Object { | ||
"payload": Object { | ||
"fromPath": "/old/hello-world-2", | ||
"ignoreCase": false, | ||
"isPermanent": false, | ||
"redirectInBrowser": false, | ||
"toPath": "//example.com", | ||
|
@@ -100,6 +108,7 @@ exports[`Add redirects creates redirects to the URL starts with ftp 1`] = ` | |
Object { | ||
"payload": Object { | ||
"fromPath": "/old/hello-world-3", | ||
"ignoreCase": false, | ||
"isPermanent": false, | ||
"redirectInBrowser": false, | ||
"toPath": "ftp://example.com", | ||
|
@@ -112,6 +121,7 @@ exports[`Add redirects creates redirects to the URL starts with http 1`] = ` | |
Object { | ||
"payload": Object { | ||
"fromPath": "/old/hello-world-1", | ||
"ignoreCase": false, | ||
"isPermanent": false, | ||
"redirectInBrowser": false, | ||
"toPath": "http://example.com", | ||
|
@@ -124,6 +134,7 @@ exports[`Add redirects creates redirects to the URL starts with https 1`] = ` | |
Object { | ||
"payload": Object { | ||
"fromPath": "/old/hello-world-0", | ||
"ignoreCase": false, | ||
"isPermanent": false, | ||
"redirectInBrowser": false, | ||
"toPath": "https://example.com", | ||
|
@@ -136,6 +147,7 @@ exports[`Add redirects creates redirects to the URL starts with mailto 1`] = ` | |
Object { | ||
"payload": Object { | ||
"fromPath": "/old/hello-world-4", | ||
"ignoreCase": false, | ||
"isPermanent": false, | ||
"redirectInBrowser": false, | ||
"toPath": "mailto:[email protected]", | ||
|
@@ -148,6 +160,7 @@ exports[`Add redirects creates redirects with in-browser redirect option 1`] = ` | |
Object { | ||
"payload": Object { | ||
"fromPath": "/old/hello-world", | ||
"ignoreCase": false, | ||
"isPermanent": false, | ||
"redirectInBrowser": true, | ||
"toPath": "/new/hello-world", | ||
|
@@ -160,6 +173,7 @@ exports[`Add redirects with path prefixs allows you to add redirects 1`] = ` | |
Object { | ||
"payload": Object { | ||
"fromPath": "/blog/old/hello-world", | ||
"ignoreCase": false, | ||
"isPermanent": false, | ||
"redirectInBrowser": false, | ||
"toPath": "/blog/new/hello-world", | ||
|
@@ -172,6 +186,7 @@ exports[`Add redirects with path prefixs create redirects as permanent 1`] = ` | |
Object { | ||
"payload": Object { | ||
"fromPath": "/blog/old/hello-world", | ||
"ignoreCase": false, | ||
"isPermanent": true, | ||
"redirectInBrowser": false, | ||
"toPath": "/blog/new/hello-world", | ||
|
@@ -184,6 +199,7 @@ exports[`Add redirects with path prefixs creates redirects from the URL starts w | |
Object { | ||
"payload": Object { | ||
"fromPath": "//example.com", | ||
"ignoreCase": false, | ||
"isPermanent": false, | ||
"redirectInBrowser": false, | ||
"toPath": "/blog/new/hello-world-2", | ||
|
@@ -196,6 +212,7 @@ exports[`Add redirects with path prefixs creates redirects from the URL starts w | |
Object { | ||
"payload": Object { | ||
"fromPath": "ftp://example.com", | ||
"ignoreCase": false, | ||
"isPermanent": false, | ||
"redirectInBrowser": false, | ||
"toPath": "/blog/new/hello-world-3", | ||
|
@@ -208,6 +225,7 @@ exports[`Add redirects with path prefixs creates redirects from the URL starts w | |
Object { | ||
"payload": Object { | ||
"fromPath": "http://example.com", | ||
"ignoreCase": false, | ||
"isPermanent": false, | ||
"redirectInBrowser": false, | ||
"toPath": "/blog/new/hello-world-1", | ||
|
@@ -220,6 +238,7 @@ exports[`Add redirects with path prefixs creates redirects from the URL starts w | |
Object { | ||
"payload": Object { | ||
"fromPath": "https://example.com", | ||
"ignoreCase": false, | ||
"isPermanent": false, | ||
"redirectInBrowser": false, | ||
"toPath": "/blog/new/hello-world-0", | ||
|
@@ -232,6 +251,7 @@ exports[`Add redirects with path prefixs creates redirects from the URL starts w | |
Object { | ||
"payload": Object { | ||
"fromPath": "mailto:[email protected]", | ||
"ignoreCase": false, | ||
"isPermanent": false, | ||
"redirectInBrowser": false, | ||
"toPath": "/blog/new/hello-world-4", | ||
|
@@ -244,6 +264,7 @@ exports[`Add redirects with path prefixs creates redirects to the URL starts wit | |
Object { | ||
"payload": Object { | ||
"fromPath": "/blog/old/hello-world-2", | ||
"ignoreCase": false, | ||
"isPermanent": false, | ||
"redirectInBrowser": false, | ||
"toPath": "//example.com", | ||
|
@@ -256,6 +277,7 @@ exports[`Add redirects with path prefixs creates redirects to the URL starts wit | |
Object { | ||
"payload": Object { | ||
"fromPath": "/blog/old/hello-world-3", | ||
"ignoreCase": false, | ||
"isPermanent": false, | ||
"redirectInBrowser": false, | ||
"toPath": "ftp://example.com", | ||
|
@@ -268,6 +290,7 @@ exports[`Add redirects with path prefixs creates redirects to the URL starts wit | |
Object { | ||
"payload": Object { | ||
"fromPath": "/blog/old/hello-world-1", | ||
"ignoreCase": false, | ||
"isPermanent": false, | ||
"redirectInBrowser": false, | ||
"toPath": "http://example.com", | ||
|
@@ -280,6 +303,7 @@ exports[`Add redirects with path prefixs creates redirects to the URL starts wit | |
Object { | ||
"payload": Object { | ||
"fromPath": "/blog/old/hello-world-0", | ||
"ignoreCase": false, | ||
"isPermanent": false, | ||
"redirectInBrowser": false, | ||
"toPath": "https://example.com", | ||
|
@@ -292,6 +316,7 @@ exports[`Add redirects with path prefixs creates redirects to the URL starts wit | |
Object { | ||
"payload": Object { | ||
"fromPath": "/blog/old/hello-world-4", | ||
"ignoreCase": false, | ||
"isPermanent": false, | ||
"redirectInBrowser": false, | ||
"toPath": "mailto:[email protected]", | ||
|
@@ -304,6 +329,7 @@ exports[`Add redirects with path prefixs creates redirects with in-browser redir | |
Object { | ||
"payload": Object { | ||
"fromPath": "/blog/old/hello-world", | ||
"ignoreCase": false, | ||
"isPermanent": false, | ||
"redirectInBrowser": true, | ||
"toPath": "/blog/new/hello-world", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.