Skip to content

Required parameter is empty string if trailing slash provided #3284

@adamreisnz

Description

@adamreisnz

I'm not sure if this is expected behaviour or not, but it seems to me like a bug (in 1.0.0-rc1).

Consider the following state declaration:

$stateProvider.state('verifyEmail', {
    parent: 'portal',
    url: '/email/verify/:token/:optional',
    component: 'verifyEmail',
    params: {
      token: {
        type: 'string',
      },
      optional: {
        value: null,
        squash: true,
      },
    },
  });

Now what happens is that if I browse to /email/verify it results in a 404, because the route is not found due to the missing token parameter. However, browsing to /email/verify/ with a trailing slash, does load the route and the token parameter is an empty string.

I was under the impression that with the above declaration, the token parameter would in fact be mandatory. If there's nothing behind the trailing slash, then the token parameter should be undefined I think and not load the route, rather than being converted to an empty string.

Now I am still required to check if the token parameter is in fact there in my component, or register a transition event handler, which seems redundant.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions