VirtusLab-Open-Source / strapi-plugin-navigation

A plugin for Strapi Headless CMS that provides navigation / menu builder feature with their possibility to control the audience and different output structure renderers like (flat, tree and RFR - ready for handling by Redux First Router)
MIT License
308 stars 57 forks source link

Using `/` as the URL doesn't work as expected. #366

Closed RemiKalbe closed 1 year ago

RemiKalbe commented 1 year ago

Let's say I have some page where I want it to be available at /.

CleanShot 2023-08-09 at 16 22 04@2x

The output path show / which is expected, then I try to query my navigation using GraphQL:

query {
  renderNavigation(
    navigationIdOrSlug: "main-navigation"
    locale: "fr"
    path: "/"
  ) {
    id
    title
    path
    related {
      id
      attributes {
        __typename
        ... on Page {
          Title
        }
      }
    }
  }
}

But it returns nothing

CleanShot 2023-08-09 at 16 24 34@2x

After some investigation I found that I actually have to write path: "//" instead of path: "/"

CleanShot 2023-08-09 at 16 25 20@2x

It doesn't end there! Let's add a nested route to it

CleanShot 2023-08-09 at 16 26 02@2x

As you can see the expected path is /nested, but again, it doesn't work, the actual path that work is ///nested

CleanShot 2023-08-09 at 16 26 39@2x
RemiKalbe commented 1 year ago

After looking at the codebase I think the fix would be to allow having an empty URL if it's the root?

CodeVoyager commented 1 year ago

Hi @RemiKalbe

There's a PR covering your issue. Have a look, please.

cyp3rius commented 1 year ago

Fixed in version 2.2.14