-
Notifications
You must be signed in to change notification settings - Fork 10.3k
feat(gatsby): trailingSlash config option
#34268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 22 commits
Commits
Show all changes
76 commits
Select commit
Hold shift + click to select a range
49f1672
config option
LekoArts 1e7646c
Merge branch 'master' into trailing-slash
LekoArts db532e4
ssr part
LekoArts 0f8f353
docs, types
LekoArts 55d47aa
move applyTrailingSlash to gatsby-page-utils
LekoArts 248877f
dev-404-page handling
LekoArts 396f986
snapshot update
LekoArts 40aea6f
wip
LekoArts d590d4f
docs
LekoArts d4a149c
add todo
LekoArts dae6ddb
gatsby-link :yey:
LekoArts 5e02152
move func into option if case
LekoArts 8949a3e
put rewriteLinkPath to own file + add unit tests
LekoArts 6648b77
fix order of args
LekoArts 992c6d6
fix number behavior
LekoArts 9b2acc5
e2e test addition
LekoArts b6fdb4d
circle ci addition
LekoArts 429c75e
silence warning
LekoArts ba4dbd9
revert create-path
LekoArts 07f9343
use createPath + applyTrailingSlashOption
LekoArts 3909933
begin derive-path work
LekoArts aeec8fd
Merge branch 'master' into trailing-slash
LekoArts 9a89baa
Merge branch 'master' into trailing-slash
LekoArts abd7c02
change derivePath function
LekoArts c539129
add client-only and index page
LekoArts 7213133
remove unused import
LekoArts be16962
handle route params + make ignore work?
LekoArts 6c8e3bc
splat routes + gatsbyPath
LekoArts 0623374
fix ts error
LekoArts 1074661
use npm-run-all
LekoArts 531d42a
prep tests
LekoArts b062129
always
LekoArts 3a5c0a4
fix gatsbyPath
LekoArts 8147f56
update tests
LekoArts 97e6a3c
update trailingSlash ts type
LekoArts 5a81041
Merge branch 'master' into trailing-slash
LekoArts 0708e46
Update types.ts
LekoArts a5c77da
add cypress dashboard entries
LekoArts d7963af
update cypress script to record
LekoArts 10996bd
Merge branch 'master' into trailing-slash
LekoArts 5cab2e4
update package.json from merge
LekoArts f8b9d2e
tmp
LekoArts a370934
Merge branch 'master' into trailing-slash
LekoArts 0a522d4
use regex for local-link and add test
LekoArts a6244b4
clean between test runs
LekoArts d2477bb
feat(gatsby): Send config keys over IPC (#34411)
LekoArts 917d2be
Merge branch 'master' into trailing-slash
LekoArts 1b3b47f
get tests to pass?
LekoArts 1887b51
Merge branch 'master' into trailing-slash
LekoArts ecdfa26
update script
LekoArts 1bd7cca
add legacy tests
LekoArts 94b1e78
wip dev
LekoArts 267f6cd
add express middleware
LekoArts a583544
tests
LekoArts 84fb2cf
Update legacy.js
LekoArts 3cb65ed
Update legacy.js
LekoArts bb9b1d8
Update serve.ts
LekoArts 0970fbf
Merge branch 'master' into trailing-slash
LekoArts 43537d8
split up tests into more fine-grained
LekoArts 3cf0dc2
format
LekoArts 0a8dfc0
add clean in between build & develop + darkmode
LekoArts 257febb
fix two smaller todos
LekoArts 8b448ce
fix(gatsby-plugin-gatsby-cloud): Revert removal of _gatsby-config.jso…
marvinjude 60ff0ab
Update packages/gatsby-plugin-gatsby-cloud/src/create-site-config.js
LekoArts b3f4783
feat(gatsby): Add telemetry tracking for trailing slash option (#34529)
marvinjude a501683
change local-link
LekoArts 4ee7ff6
Merge branch 'master' into trailing-slash
LekoArts 159969b
feat(gatsby): clear cache when trailing slash option changes (#34547)
marvinjude dd8cc06
test(gatsby): Trailing slash client only splat (#34538)
tyhopp 9bffe80
Merge branch 'master' into trailing-slash
LekoArts 820bba8
Update package.json
LekoArts 8f034c6
test(gatsby): Assert 301 redirects in E2E Tests (#34554)
marvinjude 8235639
Apply suggestions from code review
LekoArts 50f1ae5
fix lint
LekoArts ad04771
code review
LekoArts caafd5c
Merge remote-tracking branch 'upstream/master' into trailing-slash
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,13 @@ | ||
| # Project dependencies | ||
| .cache | ||
| node_modules | ||
| yarn-error.log | ||
|
|
||
| # Build assets | ||
| /public | ||
| .DS_Store | ||
| /assets | ||
|
|
||
| # Cypress output | ||
| cypress/videos/ | ||
| cypress/screenshots/ |
This file contains hidden or 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,3 @@ | ||
| # trailing-slash E2E Test | ||
|
|
||
| TODO |
This file contains hidden or 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,3 @@ | ||
| { | ||
| "videoUploadOnPasses": false | ||
| } |
This file contains hidden or 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,5 @@ | ||
| { | ||
| "name": "Using fixtures to represent data", | ||
| "email": "[email protected]", | ||
| "body": "Fixtures are a great way to mock data for responses to routes" | ||
| } |
This file contains hidden or 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,71 @@ | ||
| describe(`always`, () => { | ||
| beforeEach(() => { | ||
| cy.visit(`/`).waitForRouteChange() | ||
| }) | ||
| it(`page-creator without slash`, () => { | ||
| cy.getTestElement(`page-creator-without`).click() | ||
| cy.waitForRouteChange() | ||
| .assertRoute(`/page-2/`) | ||
| }) | ||
| it(`page-creator with slash`, () => { | ||
| cy.getTestElement(`page-creator-with`).click() | ||
| cy.waitForRouteChange() | ||
| .assertRoute(`/page-2/`) | ||
| }) | ||
| it(`create-page with slash`, () => { | ||
| cy.getTestElement(`create-page-with`).click() | ||
| cy.waitForRouteChange() | ||
| .assertRoute(`/create-page/with/`) | ||
| }) | ||
| it(`create-page without slash`, () => { | ||
| cy.getTestElement(`create-page-without`).click() | ||
| cy.waitForRouteChange() | ||
| .assertRoute(`/create-page/without/`) | ||
| }) | ||
| it(`fs-api with slash`, () => { | ||
| cy.getTestElement(`fs-api-with`).click() | ||
| cy.waitForRouteChange() | ||
| .assertRoute(`/fs-api/with/`) | ||
| }) | ||
| it(`fs-api without slash`, () => { | ||
| cy.getTestElement(`fs-api-without`).click() | ||
| cy.waitForRouteChange() | ||
| .assertRoute(`/fs-api/without/`) | ||
| }) | ||
| it(`hash`, () => { | ||
| cy.getTestElement(`hash`).click() | ||
| cy.waitForRouteChange() | ||
| .assertRoute(`/page-2/#anchor`) | ||
| }) | ||
| it(`query-param`, () => { | ||
| cy.getTestElement(`query-param`).click() | ||
| cy.waitForRouteChange() | ||
| .assertRoute(`/page-2/?query_param=hello`) | ||
| }) | ||
| it(`query-param-hash`, () => { | ||
| cy.getTestElement(`query-param-hash`).click() | ||
| cy.waitForRouteChange() | ||
| .assertRoute(`/page-2/?query_param=hello#anchor`) | ||
| }) | ||
| }) | ||
|
|
||
| if (Cypress.env(`IS_BUILD`)) { | ||
| describe(`always (direct visits)`, () => { | ||
| it(`page-creator`, () => { | ||
| cy.visit(`/page-2`).waitForRouteChange() | ||
| .assertRoute(`/page-2/`) | ||
| }) | ||
| it(`create-page`, () => { | ||
| cy.visit(`/create-page/with/`).waitForRouteChange() | ||
| .assertRoute(`/create-page/with/`) | ||
| cy.visit(`/create-page/without`).waitForRouteChange() | ||
| .assertRoute(`/create-page/without/`) | ||
| }) | ||
| it(`fs-api`, () => { | ||
| cy.visit(`/fs-api/with/`).waitForRouteChange() | ||
| .assertRoute(`/fs-api/with/`) | ||
| cy.visit(`/fs-api/without`).waitForRouteChange() | ||
| .assertRoute(`/fs-api/without/`) | ||
| }) | ||
| }) | ||
| } |
This file contains hidden or 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,71 @@ | ||
| describe(`ignore`, () => { | ||
| beforeEach(() => { | ||
| cy.visit(`/`).waitForRouteChange() | ||
| }) | ||
| it(`page-creator without slash`, () => { | ||
| cy.getTestElement(`page-creator-without`).click() | ||
| cy.waitForRouteChange() | ||
| .assertRoute(`/page-2/`) | ||
| }) | ||
| it(`page-creator with slash`, () => { | ||
| cy.getTestElement(`page-creator-with`).click() | ||
| cy.waitForRouteChange() | ||
| .assertRoute(`/page-2/`) | ||
| }) | ||
| it(`create-page with slash`, () => { | ||
| cy.getTestElement(`create-page-with`).click() | ||
| cy.waitForRouteChange() | ||
| .assertRoute(`/create-page/with/`) | ||
| }) | ||
| it(`create-page without slash`, () => { | ||
| cy.getTestElement(`create-page-without`).click() | ||
| cy.waitForRouteChange() | ||
| .assertRoute(`/create-page/without`) | ||
| }) | ||
| it(`fs-api with slash`, () => { | ||
| cy.getTestElement(`fs-api-with`).click() | ||
| cy.waitForRouteChange() | ||
| .assertRoute(`/fs-api/with/`) | ||
| }) | ||
| it(`fs-api without slash`, () => { | ||
| cy.getTestElement(`fs-api-without`).click() | ||
| cy.waitForRouteChange() | ||
| .assertRoute(`/fs-api/without`) | ||
| }) | ||
| it(`hash`, () => { | ||
| cy.getTestElement(`hash`).click() | ||
| cy.waitForRouteChange() | ||
| .assertRoute(`/page-2/#anchor`) | ||
| }) | ||
| it(`query-param`, () => { | ||
| cy.getTestElement(`query-param`).click() | ||
| cy.waitForRouteChange() | ||
| .assertRoute(`/page-2/?query_param=hello`) | ||
| }) | ||
| it(`query-param-hash`, () => { | ||
| cy.getTestElement(`query-param-hash`).click() | ||
| cy.waitForRouteChange() | ||
| .assertRoute(`/page-2/?query_param=hello#anchor`) | ||
| }) | ||
| }) | ||
|
|
||
| if (Cypress.env(`IS_BUILD`)) { | ||
| describe(`ignore (direct visits)`, () => { | ||
| it(`page-creator`, () => { | ||
| cy.visit(`/page-2`).waitForRouteChange() | ||
| .assertRoute(`/page-2/`) | ||
| }) | ||
| it(`create-page`, () => { | ||
| cy.visit(`/create-page/with/`).waitForRouteChange() | ||
| .assertRoute(`/create-page/with/`) | ||
| cy.visit(`/create-page/without`).waitForRouteChange() | ||
| .assertRoute(`/create-page/without`) | ||
| }) | ||
| it(`fs-api`, () => { | ||
| cy.visit(`/fs-api/with/`).waitForRouteChange() | ||
| .assertRoute(`/fs-api/with/`) | ||
| cy.visit(`/fs-api/without`).waitForRouteChange() | ||
| .assertRoute(`/fs-api/without`) | ||
| }) | ||
| }) | ||
| } |
This file contains hidden or 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,71 @@ | ||
| describe(`never`, () => { | ||
| beforeEach(() => { | ||
| cy.visit(`/`).waitForRouteChange() | ||
| }) | ||
| it(`page-creator without slash`, () => { | ||
| cy.getTestElement(`page-creator-without`).click() | ||
| cy.waitForRouteChange() | ||
| .assertRoute(`/page-2`) | ||
| }) | ||
| it(`page-creator with slash`, () => { | ||
| cy.getTestElement(`page-creator-with`).click() | ||
| cy.waitForRouteChange() | ||
| .assertRoute(`/page-2`) | ||
| }) | ||
| it(`create-page with slash`, () => { | ||
| cy.getTestElement(`create-page-with`).click() | ||
| cy.waitForRouteChange() | ||
| .assertRoute(`/create-page/with`) | ||
| }) | ||
| it(`create-page without slash`, () => { | ||
| cy.getTestElement(`create-page-without`).click() | ||
| cy.waitForRouteChange() | ||
| .assertRoute(`/create-page/without`) | ||
| }) | ||
| it(`fs-api with slash`, () => { | ||
| cy.getTestElement(`fs-api-with`).click() | ||
| cy.waitForRouteChange() | ||
| .assertRoute(`/fs-api/with`) | ||
| }) | ||
| it(`fs-api without slash`, () => { | ||
| cy.getTestElement(`fs-api-without`).click() | ||
| cy.waitForRouteChange() | ||
| .assertRoute(`/fs-api/without`) | ||
| }) | ||
| it(`hash`, () => { | ||
| cy.getTestElement(`hash`).click() | ||
| cy.waitForRouteChange() | ||
| .assertRoute(`/page-2#anchor`) | ||
| }) | ||
| it(`query-param`, () => { | ||
| cy.getTestElement(`query-param`).click() | ||
| cy.waitForRouteChange() | ||
| .assertRoute(`/page-2?query_param=hello`) | ||
| }) | ||
| it(`query-param-hash`, () => { | ||
| cy.getTestElement(`query-param-hash`).click() | ||
| cy.waitForRouteChange() | ||
| .assertRoute(`/page-2?query_param=hello#anchor`) | ||
| }) | ||
| }) | ||
|
|
||
| if (Cypress.env(`IS_BUILD`)) { | ||
| describe(`never (direct visits)`, () => { | ||
| it(`page-creator`, () => { | ||
| cy.visit(`/page-2`).waitForRouteChange() | ||
| .assertRoute(`/page-2`) | ||
| }) | ||
| it(`create-page`, () => { | ||
| cy.visit(`/create-page/with/`).waitForRouteChange() | ||
| .assertRoute(`/create-page/with`) | ||
| cy.visit(`/create-page/without`).waitForRouteChange() | ||
| .assertRoute(`/create-page/without`) | ||
| }) | ||
| it(`fs-api`, () => { | ||
| cy.visit(`/fs-api/with/`).waitForRouteChange() | ||
| .assertRoute(`/fs-api/with`) | ||
| cy.visit(`/fs-api/without`).waitForRouteChange() | ||
| .assertRoute(`/fs-api/without`) | ||
| }) | ||
| }) | ||
| } |
This file contains hidden or 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,17 @@ | ||
| // *********************************************************** | ||
| // This example plugins/index.js can be used to load plugins | ||
| // | ||
| // You can change the location of this file or turn off loading | ||
| // the plugins file with the 'pluginsFile' configuration option. | ||
| // | ||
| // You can read more here: | ||
| // https://on.cypress.io/plugins-guide | ||
| // *********************************************************** | ||
|
|
||
| // This function is called when a project is opened or re-opened (e.g. due to | ||
| // the project's config changing) | ||
|
|
||
| module.exports = (on, config) => { | ||
| // `on` is used to hook into various events Cypress emits | ||
| // `config` is the resolved Cypress config | ||
| } |
This file contains hidden or 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,3 @@ | ||
| Cypress.Commands.add(`assertRoute`, route => { | ||
| cy.url().should(`equal`, `${window.location.origin}${route}`) | ||
| }) |
This file contains hidden or 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,2 @@ | ||
| import "gatsby-cypress" | ||
| import "./commands" |
This file contains hidden or 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,11 @@ | ||
| console.log('env var', process.env.TRAILING_SLASH) | ||
|
|
||
| module.exports = { | ||
| trailingSlash: process.env.TRAILING_SLASH || `legacy`, | ||
| siteMetadata: { | ||
| siteMetadata: { | ||
| siteUrl: `https://www.domain.tld`, | ||
| title: `Trailing Slash`, | ||
| }, | ||
| }, | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.