Skip to content

Commit

Permalink
Warn if trying to create a page whose path is similarly slashed (#13470)
Browse files Browse the repository at this point in the history
  • Loading branch information
Moocar authored and KyleAMathews committed Apr 18, 2019
1 parent 0b56c3b commit b0cdba5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/gatsby/src/redux/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,18 @@ ${reservedFields.map(f => ` * "${f}"`).join(`\n`)}
const contextModified =
!!oldPage && !_.isEqual(oldPage.context, internalPage.context)

const alternateSlashPath = page.path.endsWith(`/`)
? page.path.slice(0, -1)
: page.path + `/`

if (store.getState().pages.has(alternateSlashPath)) {
report.warn(
`Attempting to create page "${
page.path
}", but page "${alternateSlashPath}" already exists. This could lead to non-deterministic routing behavior`
)
}

return {
...actionOptions,
type: `CREATE_PAGE`,
Expand Down

0 comments on commit b0cdba5

Please sign in to comment.