angular / angular

Deliver web apps with confidence 🚀
https://angular.dev
MIT License
96.09k stars 25.43k forks source link

Route param does not allow '@' before it, for example '@:param' will not work #19868

Closed lansana closed 3 years ago

lansana commented 7 years ago

I'm submitting a...

[X] Feature request

Current behavior

Trying to access the path /@username in my app, but the catchall route is being caught instead.

Expected behavior

I want it to navigate to my ProfileModule that is at the @:username path.

Minimal reproduction of the problem with instructions

Add this route to your app routes:

const routes: Routes = [
    {
        path: '',
        pathMatch: 'full',
        loadChildren: './home/home.module#HomeModule'
    },
    // ...
    {
        path: '@:username',
        loadChildren: './profile/profile.module#ProfileModule'
    },
    {
        path: '**',
        redirectTo: 'foo'
    }
];

export const AppRoutesModule = RouterModule.forRoot(routes);

Environment

Angular version: 4.3.5

Browser: Chrome (desktop) version 59

For Tooling issues:

Here is the related stackoverflow post I made: https://stackoverflow.com/questions/46880756/angular2-routes-does-not-allow-param-in-route-param

skatterwe commented 7 years ago

Ich kehre zurück am 01.11.2017.

Ich werde Ihre Nachricht nach meiner Rückkehr beantworten. In dringenden Fällen senden Sie bitte eine Kopie Ihrer E-Mail für technische Angelegenheiten an entwicklung@arxes-tolina.de, ansonsten an info@arxes-tolina.de. Ein anderer Mitarbeiter wird sich dann Ihrer E-Mail annehmen.

Hinweis: Dies ist eine automatische Antwort auf Ihre Nachricht "[angular/angular] Route param does not allow '@' before it, for example '@:param' will not work (#19868)" gesendet am 23.10.2017 13:17:12.

Diese ist die einzige Benachrichtigung, die Sie empfangen werden, während diese Person abwesend ist.

mlc-mlapis commented 7 years ago

@lansana ... where did you find that there is a general pattern like path: '@:anykey'.

The only pattern is just :anykey, usually in the concrete form as :id or route/:id.

lansana commented 7 years ago

@mlc-mlapis I figured the router was smart enough to notice the :param from anywhere in the path, sort of like if you do something like /foo/:id.

I don't see why it can't match against /@:id if it can do something like /foo/:id.

Example use case from Medium: https://medium.com/@Lansana

mlc-mlapis commented 7 years ago

@lansana ... hmm, the difference is the slash is not followed by a colon ... /@:id here @. It is related how router is parsing the URL segments and what is and what is not allowed.

So your observation could lead to a new request but certainly not to a bug issue.

lansana commented 7 years ago

@mlc-mlapis Good point, I guess. I changed it from bug to feature request. May just make a pull request... I would really like this. I think the ability to prefix routes intuitive. AngularJS ui-router had this ability, many other framework/library routers have this ability as well.

jasonaden commented 6 years ago

Thanks for the request @lansana. I think the use case makes sense, though you could also create a custom UrlSerializer. Currently we're using this one.

angular-robot[bot] commented 3 years ago

Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.

Find more details about Angular's feature request process in our documentation.

angular-robot[bot] commented 3 years ago

Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.

We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.

You can find more details about the feature request process in our documentation.

angular-automatic-lock-bot[bot] commented 3 years ago

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.