emberjs / emberjs/ember.js

[Bug] resetNamespace allows duplicate route names, unstable URL behavior

Open
#19,066 0 comments 0 reactions 0 assignees View on GitHub
Routing
Dominant language
TypeScript
Stars
22.6k
Forks
4.2k
Avg merge
3d 12h
Merged PRs (30d)
15

Description

### 🐞 Describe the Bug
Using [resetNamespace](https://api.emberjs.com/ember/3.20/classes/EmberRouter/methods/map?anchor=map), you can create two routes with the same route name, causing the same URL to map to different routes under different circumstances.

### 🔬 Minimal Reproduction
https://ember-twiddle.com/79653f3affde1ea19ecc8211c26b0b8b?openFiles=router%5C.js%2C

1. Enter `/foo/details` in the twiddle url bar. The DOM shows the foo details route, but the URL is modified to be `/bar/baz/details`
2. Hit enter again in the URL bar, essentially refreshing `/bar/baz/details`. Now the DOM changes to reflect the bar baz details route.
3. Now enter `/foo/details` in the URL bar again and hit enter. Now the DOM actually reflects the foo details route.

### 😕 Actual Behavior
Same URL shows a different route, depending on ordering of route invocations.

### 🤔 Expected Behavior
1. I would expect an assertion to be thrown in development if there are two different routes with the same name.
2. In production, I would still expect the same URL to be stable

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.