+ const nextSearchParams = nextUrl.searchParams
+ nextSearchParams.delete('a-state')
+
+ const previousSearchParams = previousUrl.searchParams
+
+ nextSearchParams.sort()
+ previousSearchParams.sort()
+
+ if (nextSearchParams.toString() !== previousSearchParams.toString()) {
+ resetScroll = true
+ }
+ } catch (e) {
+ console.error('Cannot parse URL to check next scroll.', e)
+ resetScroll = true
+ }
+ })
+
+ navigationEndEvent.pipe(
+ map(() => window.location.pathname),
+ filter(pathname => !pathname || pathname === '/' || is18nPath(pathname))
+ ).subscribe(() => this.redirectService.redirectToHomepage(true))
+
+ navigationEndEvent.subscribe(e => {
+ this.hooks.runAction('action:router.navigation-end', 'common', { path: e.url })
+ })
+
+ eventsObs.pipe(
+ filter((e: Event): e is GuardsCheckStart => e instanceof GuardsCheckStart),
+ filter(() => this.screenService.isInSmallView())
+ ).subscribe(() => this.menu.isMenuDisplayed = false) // User clicked on a link in the menu, change the page
+ }
+
+ private injectJS () {
+ // Inject JS
+ this.serverService.getConfig()
+ .subscribe(config => {
+ if (config.instance.customizations.javascript) {
+ try {
+ // tslint:disable:no-eval
+ eval(config.instance.customizations.javascript)
+ } catch (err) {
+ console.error('Cannot eval custom JavaScript.', err)
+ }
+ }
+ })
+ }
+
+ private injectCSS () {
+ // Inject CSS if modified (admin config settings)
+ this.serverService.configReloaded
+ .subscribe(() => {
+ const headStyle = document.querySelector('style.custom-css-style')
+ if (headStyle) headStyle.parentNode.removeChild(headStyle)
+
+ // We test customCSS if the admin removed the css
+ if (this.customCSS || this.serverConfig.instance.customizations.css) {
+ const styleTag = '<style>' + this.serverConfig.instance.customizations.css + '</style>'
+ this.customCSS = this.domSanitizer.bypassSecurityTrustHtml(styleTag)