Skip to content

Commit

Permalink
fix: multi site not working language switch (#649)
Browse files Browse the repository at this point in the history
- using non normalized LocationStrategy instead of Location that strips the needed BaseHref
  • Loading branch information
jometzner authored Apr 14, 2021
1 parent fa2b104 commit 3c01d7d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/app/core/pipes/make-href.pipe.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Location } from '@angular/common';
import { LocationStrategy } from '@angular/common';
import { TestBed } from '@angular/core/testing';

import { MakeHrefPipe } from './make-href.pipe';
Expand Down Expand Up @@ -28,6 +28,6 @@ describe('Make Href Pipe', () => {
['/test?query=q', { foo: 'bar' }, '/test;foo=bar?query=q'],
['/test?query=q', { foo: 'bar', marco: 'polo' }, '/test;foo=bar;marco=polo?query=q'],
])(`should transform "%s" with %j to "%s"`, (url, params, expected) => {
expect(makeHrefPipe.transform({ path: () => url } as Location, params)).toEqual(expected);
expect(makeHrefPipe.transform({ path: () => url } as LocationStrategy, params)).toEqual(expected);
});
});
4 changes: 2 additions & 2 deletions src/app/core/pipes/make-href.pipe.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Location } from '@angular/common';
import { LocationStrategy } from '@angular/common';
import { Pipe, PipeTransform } from '@angular/core';

@Pipe({ name: 'makeHref', pure: false })
export class MakeHrefPipe implements PipeTransform {
transform(location: Location, urlParams: { [key: string]: string }): string {
transform(location: LocationStrategy, urlParams: { [key: string]: string }): string {
if (!location || !location.path()) {
return 'undefined';
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Location } from '@angular/common';
import { LocationStrategy } from '@angular/common';
import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core';
import { Observable } from 'rxjs';

Expand All @@ -20,7 +20,7 @@ export class LanguageSwitchComponent implements OnInit {
locale$: Observable<Locale>;
availableLocales$: Observable<Locale[]>;

constructor(private appFacade: AppFacade, public location: Location) {}
constructor(private appFacade: AppFacade, public location: LocationStrategy) {}

ngOnInit() {
this.locale$ = this.appFacade.currentLocale$;
Expand Down

0 comments on commit 3c01d7d

Please sign in to comment.