fridays / next-routes

Universal dynamic routes for Next.js
MIT License
2.47k stars 230 forks source link

Route getAs and getHref return `?` when route.add has regular with empty optional param #97

Closed polovi closed 7 years ago

polovi commented 7 years ago
routes.add({
  name: 'home',
  pattern: '/:id([a-z0-9]{24})?',
  page: 'index',
})

If url param id isnt set route generate url with ? like /home? It needs to return ? only if toQuerystring return some query

getHref (params = {}) {
    const = qString = toQuerystring(params)
    return `${this.page}${qString !== '' ? `?${qString}` : ''}`
    //return `${this.page}?${toQuerystring(params)}`
  }
fridays commented 7 years ago

Fixed in version 1.1.0!