filter option with map results in error

manastalukdar
5
manastalukdar
commented 6 months ago

Version

1.0.0

Reproduction link

https://github.com/manastalukdar/manastalukdar.github.io

Steps to reproduce

Run "npm run nuxt-generate" from the folder website.

Results in error: Url must be a string. Received undefined

sitemap.xml does not get generated.

If I remove the filter option, everything works correctly.

Problematic code:

filter({ routes }) {
      return routes.map(route => {
        if (!route.url.endsWith('.xml') && !route.url.endsWith('/')) {
          route.url = `${route.url}/`
        }
      })
    },

I have verified that the Url has the correct value. I have also tried type casting it explicitly to String, without success.

What is expected ?

sitemap.xml gets generated and the filter option works as expected.

What is actually happening?

Results in error: Url must be a string. Received undefined

sitemap.xml does not get generated.

bug
0
manastalukdar
5
manastalukdar
commented 6 months ago

Fixed it:

filter({ routes }) {
      return routes.map(route => {
        if (!route.url.endsWith('.xml') && !route.url.endsWith('/')) {
          route.url = `${route.url}/`
        }
        return route
      })
    },
1
Informations
Bug Report โ€ข Open
#c48 - Created 6 months ago