fix(aio): strip leading slashes from path (and improve DRY-ness) (#16238)

Previously, the path returned by `LocationService.path()` preserved leading
slashes, which resulted in requests with consequtive slashes in the URL. Such
requests would fail (with a 404) on staging.

This commit fixes it, by removing leading slashes from the path. It also
refactors `LocationService` a bit, converting path to an observable,
`currentPath` (similar to `currentUrl`), and applies certain clean-ups (e.g.
stripping slashes, query, hash) in one place, which simplifies consumption.

Closes #16230
This commit is contained in:
George Kalpakas
2017-04-21 23:35:40 +03:00
committed by Miško Hevery
parent 062fc4afee
commit 9c1318d731
9 changed files with 228 additions and 97 deletions

View File

@ -7,7 +7,7 @@ import { LocationService } from 'app/shared/location.service';
*/
@Component({
selector: 'current-location',
template: '{{location.path()}}'
template: '{{ location.currentPath | async }}'
})
export class CurrentLocationComponent {
constructor(public location: LocationService) {