1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2025-01-14 14:43:17 +08:00

fixing navigation parentheses error

This commit is contained in:
Braun Patrik 2017-07-18 18:26:24 +02:00
parent 0f4eb10c91
commit 81c3b6bca0

View File

@ -53,6 +53,7 @@ import {SettingsService} from "./settings/settings.service";
import {ShareSettingsComponent} from "./settings/share/share.settings.component";
import {BasicSettingsComponent} from "./settings/basic/basic.settings.component";
import {OtherSettingsComponent} from "./settings/other/other.settings.component";
import {DefaultUrlSerializer, UrlSerializer, UrlTree} from '@angular/router';
@Injectable()
export class GoogleMapsConfig {
@ -69,6 +70,21 @@ export class MyHammerConfig extends HammerGestureConfig {
}
}
class CustomUrlSerializer implements UrlSerializer {
private _defaultUrlSerializer: DefaultUrlSerializer = new DefaultUrlSerializer();
parse(url: string): UrlTree {
// Encode parentheses
url = url.replace(/\(/g, '%28').replace(/\)/g, '%29');
// Use the default serializer.
return this._defaultUrlSerializer.parse(url)
}
serialize(tree: UrlTree): string {
return this._defaultUrlSerializer.serialize(tree).replace(/%28/g, '(').replace(/%29/g, ')');
}
}
@NgModule({
imports: [
BrowserModule,
@ -115,6 +131,7 @@ export class MyHammerConfig extends HammerGestureConfig {
OtherSettingsComponent,
StringifyRole],
providers: [
{provide: UrlSerializer, useClass: CustomUrlSerializer},
{provide: LAZY_MAPS_API_CONFIG, useClass: GoogleMapsConfig},
{provide: HAMMER_GESTURE_CONFIG, useClass: MyHammerConfig},
NetworkService,