angular/aio/src/app/embedded/current-location.component.ts
George Kalpakas 9c1318d731 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
2017-04-21 13:35:40 -07:00

16 lines
419 B
TypeScript

/* tslint:disable component-selector */
import { Component } from '@angular/core';
import { LocationService } from 'app/shared/location.service';
/**
* A simple embedded component that displays the current location path
*/
@Component({
selector: 'current-location',
template: '{{ location.currentPath | async }}'
})
export class CurrentLocationComponent {
constructor(public location: LocationService) {
}
}