Skip to content

Commit

Permalink
Merge pull request #262 from johnsardine/ignore-middleware-paths
Browse files Browse the repository at this point in the history
Ignore _middleware routes
  • Loading branch information
iamvishnusankar committed Jan 12, 2022
2 parents 3e38c0e + 66c3e39 commit cc2036a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/next-sitemap/src/url/util/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ describe('next-sitemap', () => {
expect(isNextInternalUrl('/_app')).toBeTruthy()
expect(isNextInternalUrl('/404')).toBeTruthy()
expect(isNextInternalUrl('/_random')).toBeTruthy()
expect(isNextInternalUrl('/_middleware')).toBeTruthy()
expect(isNextInternalUrl('/about/_middleware')).toBeTruthy()
expect(isNextInternalUrl('/some_url/about/_middleware')).toBeTruthy()
expect(isNextInternalUrl('/projects/[id]/_middleware')).toBeTruthy()
})

test('isNextInternalUrl: url params', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-sitemap/src/url/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const generateUrl = (baseUrl: string, slug: string): string => {
* @param path path check
*/
export const isNextInternalUrl = (path: string): boolean => {
return new RegExp(/[^\/]*^.[_]|^\/404$|(?:\[)/g).test(path)
return new RegExp(/[^\/]*^.[_]|^\/404$|\/_middleware$|(?:\[)/g).test(path)
}

/**
Expand Down

0 comments on commit cc2036a

Please sign in to comment.