Skip to content

Commit

Permalink
fix: avoid breaking change in `getPathRobotConfix: incorrect robot me…
Browse files Browse the repository at this point in the history
…ta tag

Fixes nuxt-modules/robots/is#137sues/137
  • Loading branch information
harlan-zw committed Aug 21, 2024
1 parent 8c605da commit 2801b8a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/runtime/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export function normalizeGroup(group: RobotsGroupInput): RobotsGroupResolved {
userAgent: group.userAgent ? asArray(group.userAgent) : ['*'],
disallow,
allow,
_indexable: disallow.includes((rule: string) => rule === '/'),
_indexable: !disallow.includes((rule: string) => rule === '/'),
_rules: [
...disallow.map(r => ({ pattern: r, allow: false })),
...allow.map(r => ({ pattern: r, allow: true })),
Expand Down
1 change: 1 addition & 0 deletions test/default.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@ describe('default', () => {
expect((await $fetch.raw('/users/test/hidden')).headers.get('x-robots-tag')).toMatchInlineSnapshot(`"noindex, nofollow"`)
// wildcard query
expect((await $fetch.raw('/visible?b=foo&a=bar')).headers.get('x-robots-tag')).toMatchInlineSnapshot(`"noindex, nofollow"`)
expect((await $fetch.raw('/')).headers.get('x-robots-tag')).toMatchInlineSnapshot(`"index, follow, max-image-preview:large, max-snippet:-1, max-video-preview:-1"`)
})
})

0 comments on commit 2801b8a

Please sign in to comment.