emberjs / emberjs/ember.js

[3.15] Router currentURL Not Set

Open
#18,665 9 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

In Ember 3.12 the following code would report the current URL of the application:

```
class MyRoute extends Route {
@service router;

activate() {
super.activate(...arguments);
console.log('here you are:', this.router.currentURL);
}
}
```

In Ember 3.15 this will always report `null`. This is expected to work per [RouterService#currentURL](http://api.emberjs.com/ember/3.15/classes/RouterService/properties/currentURL?anchor=currentURL). Cursory investigation shows that both `currentRouteName` nor `currentRoute` are set either.

Curiously the `RouterService` reports the correct URL when used within a Component.

Sample application: https://github.com/jherdman/where-art-thou. Note that the console will always log a `null` URL, whereas the component correctly reports the URL.

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.