MCPcopy Create free account
hub / github.com/angular/angular / constructor

Method constructor

packages/common/src/location/location.ts:69–91  ·  view source on GitHub ↗
(locationStrategy: LocationStrategy)

Source from the content-addressed store, hash-verified

67 _urlChangeSubscription: SubscriptionLike | null = null;
68
69 constructor(locationStrategy: LocationStrategy) {
70 this._locationStrategy = locationStrategy;
71 const baseHref = this._locationStrategy.getBaseHref();
72 // Note: This class's interaction with base HREF does not fully follow the rules
73 // outlined in the spec https://www.freesoft.org/CIE/RFC/1808/18.htm.
74 // Instead of trying to fix individual bugs with more and more code, we should
75 // investigate using the URL constructor and providing the base as a second
76 // argument.
77 // https://developer.mozilla.org/en-US/docs/Web/API/URL/URL#parameters
78 this._basePath = _stripOrigin(stripTrailingSlash(_stripIndexHtml(baseHref)));
79 this._locationStrategy.onPopState((ev) => {
80 const popStateEvent: PopStateEvent = {
81 'url': this.path(true),
82 'pop': true,
83 'state': ev.state,
84 'type': ev.type,
85 };
86 if (ev.hasUAVisualTransition) {
87 popStateEvent.hasUAVisualTransition = true;
88 }
89 this._subject.next(popStateEvent);
90 });
91 }
92
93 /** @docs-private */
94 ngOnDestroy(): void {

Callers

nothing calls this directly

Implementers 1

SpyLocationpackages/common/testing/src/location_m

Calls 7

pathMethod · 0.95
stripTrailingSlashFunction · 0.90
_stripOriginFunction · 0.85
_stripIndexHtmlFunction · 0.70
getBaseHrefMethod · 0.45
onPopStateMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected