diff --git a/src/app/errors/routes.ts b/src/app/errors/routes.ts index a17277f895..2141308606 100644 --- a/src/app/errors/routes.ts +++ b/src/app/errors/routes.ts @@ -7,13 +7,15 @@ type Params = { url: string; }; +const loadableArgs = { + loader: () => import(/* webpackChunkName: "LoaderCentered" */ './components/LoaderCentered'), + loading: () => null, + modules: ['LoaderCentered'], + webpack: /* istanbul ignore next */ () => [(require as any).resolveWeak('./components/LoaderCentered')], +}; + export const notFound: Route = { - component: Loadable({ - loader: () => import(/* webpackChunkName: "LoaderCentered" */ './components/LoaderCentered'), - loading: () => null, - modules: ['LoaderCentered'], - webpack: /* istanbul ignore next */ () => [(require as any).resolveWeak('./components/LoaderCentered')], - }), + component: Loadable(loadableArgs), getSearch: (params: Params): string => `path=${params.url}`, getUrl: (_params: Params) => '/error/404', name: 'NotFound', @@ -21,12 +23,7 @@ export const notFound: Route = { }; export const external: Route = { - component: Loadable({ - loader: () => import(/* webpackChunkName: "LoaderCentered" */ './components/LoaderCentered'), - loading: () => null, - modules: ['LoaderCentered'], - webpack: /* istanbul ignore next */ () => [(require as any).resolveWeak('./components/LoaderCentered')], - }), + component: Loadable(loadableArgs), getUrl: (params: Params) => params.url, name: 'External', paths: [':url(/.*)'], diff --git a/src/app/navigation/utils.spec.ts b/src/app/navigation/utils.spec.ts index ff5f621d5a..107bbeede5 100644 --- a/src/app/navigation/utils.spec.ts +++ b/src/app/navigation/utils.spec.ts @@ -65,9 +65,9 @@ describe('findRouteMatch', () => { }); it('returns undefined for missing param values', () => { - const location = {pathname: '/with'} as Location; + const location = '/with'; const result = findRouteMatch(routes, location); - expect(result).toEqual({route: routes[1], params: {param: undefined}, state: {}}); + expect(result).toEqual({route: routes[1], params: {param: undefined}, state: false}); }); });