Skip to content

Commit

Permalink
Ignore _middleware routes
Browse files Browse the repository at this point in the history
Introduced by next.js
  • Loading branch information
johnsardine committed Jan 12, 2022
1 parent 76180e4 commit c70726f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 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,9 @@ 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()
})

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 c70726f

Please sign in to comment.