2015-09-21 17:31:31 -07:00
|
|
|
/**
|
|
|
|
* `LocationStrategy` is responsible for representing and reading route state
|
|
|
|
* from the the browser's URL. Angular provides two strategies:
|
|
|
|
* {@link HashLocationStrategy} (default) and {@link PathLocationStrategy}.
|
|
|
|
*
|
|
|
|
* This is used under the hood of the {@link Location} service.
|
|
|
|
*
|
|
|
|
* Applications should use the {@link Router} or {@link Location} services to
|
|
|
|
* interact with application route state.
|
|
|
|
*
|
|
|
|
* For instance, {@link HashLocationStrategy} produces URLs like
|
|
|
|
* `http://example.com#/foo`, and {@link PathLocationStrategy} produces
|
|
|
|
* `http://example.com/foo` as an equivalent URL.
|
|
|
|
*
|
|
|
|
* See these two classes for more.
|
|
|
|
*/
|
2015-09-25 14:48:17 -07:00
|
|
|
export abstract class LocationStrategy {
|
|
|
|
abstract path(): string;
|
2015-10-26 13:57:41 +00:00
|
|
|
abstract prepareExternalUrl(internal: string): string;
|
2015-09-23 00:10:26 -07:00
|
|
|
abstract pushState(state: any, title: string, url: string, queryParams: string): void;
|
2015-09-25 14:48:17 -07:00
|
|
|
abstract forward(): void;
|
|
|
|
abstract back(): void;
|
|
|
|
abstract onPopState(fn: (_: any) => any): void;
|
|
|
|
abstract getBaseHref(): string;
|
2015-06-22 12:14:19 -07:00
|
|
|
}
|
2015-09-23 00:10:26 -07:00
|
|
|
|
|
|
|
export function normalizeQueryParams(params: string): string {
|
|
|
|
return (params.length > 0 && params.substring(0, 1) != '?') ? ('?' + params) : params;
|
|
|
|
}
|