Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/gatsby-plugin-sitemap/src/__tests__/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const { regexExclude404 } = require(`../internals`)
const { regexExclude404AndOfflineShell } = require(`../internals`)

describe(`gatsby-plugin-sitemap`, () => {
it(`regex for filtering out 404 pages`, () => {
const regex = new RegExp(regexExclude404)
const regex = new RegExp(regexExclude404AndOfflineShell)

// 404 pages
expect(regex.exec(`/404`)).toBeNull()
Expand All @@ -11,9 +11,13 @@ describe(`gatsby-plugin-sitemap`, () => {
expect(regex.exec(`/404page`)).toBeNull()
expect(regex.exec(`/404-and-now-anything`)).toBeNull()

// gatsby-plugin-offline app shell fallback
expect(regex.exec(`/offline-plugin-app-shell-fallback`)).toBeNull()

// Generic valid pages
expect(regex.exec(`/my-page`)).not.toBeNull()
expect(regex.exec(`/my-page-404123`)).not.toBeNull()
expect(regex.exec(`/my-page-404`)).not.toBeNull()
expect(regex.exec(`/my-offline-plugin-app-shell-fallback`)).not.toBeNull()
})
})
4 changes: 2 additions & 2 deletions packages/gatsby-plugin-sitemap/src/internals.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const runQuery = (handler, query) =>
return r.data
})

export const regexExclude404 = /^(?!\/(dev-404-page|404)).*$/
export const regexExclude404AndOfflineShell = /^(?!\/(dev-404-page|404|offline-plugin-app-shell-fallback)).*$/

export const defaultOptions = {
query: `
Expand All @@ -26,7 +26,7 @@ export const defaultOptions = {
allSitePage(
filter: {
path: {
regex: "${regexExclude404}"
regex: "${regexExclude404AndOfflineShell}"
}
}
) {
Expand Down