diff --git a/x-pack/plugins/reporting/server/export_types/common/get_absolute_url.test.ts b/x-pack/plugins/reporting/server/export_types/common/get_absolute_url.test.ts index cb792fbd6ae039..0b06beabfd24dc 100644 --- a/x-pack/plugins/reporting/server/export_types/common/get_absolute_url.test.ts +++ b/x-pack/plugins/reporting/server/export_types/common/get_absolute_url.test.ts @@ -7,7 +7,7 @@ import { getAbsoluteUrlFactory } from './get_absolute_url'; const defaultOptions = { - defaultBasePath: 'sbp', + basePath: 'sbp', protocol: 'http:', hostname: 'localhost', port: 5601, @@ -64,8 +64,8 @@ test(`uses the provided hash with queryString`, () => { }); test(`uses the provided basePath`, () => { - const getAbsoluteUrl = getAbsoluteUrlFactory(defaultOptions); - const absoluteUrl = getAbsoluteUrl({ basePath: '/s/marketing' }); + const getAbsoluteUrl = getAbsoluteUrlFactory({ ...defaultOptions, basePath: '/s/marketing' }); + const absoluteUrl = getAbsoluteUrl(); expect(absoluteUrl).toBe(`http://localhost:5601/s/marketing/app/kibana`); }); diff --git a/x-pack/plugins/reporting/server/export_types/common/get_absolute_url.ts b/x-pack/plugins/reporting/server/export_types/common/get_absolute_url.ts index aca6432ad26e77..72305f47e71897 100644 --- a/x-pack/plugins/reporting/server/export_types/common/get_absolute_url.ts +++ b/x-pack/plugins/reporting/server/export_types/common/get_absolute_url.ts @@ -7,7 +7,7 @@ import url from 'url'; interface AbsoluteURLFactoryOptions { - defaultBasePath: string; + basePath: string; protocol: string; hostname: string; port: string | number; @@ -17,14 +17,9 @@ export const getAbsoluteUrlFactory = ({ protocol, hostname, port, - defaultBasePath, // never gets an override + basePath, }: AbsoluteURLFactoryOptions) => { - return function getAbsoluteUrl({ - basePath = defaultBasePath, // unused - hash = '', - path = '/app/kibana', - search = '', - } = {}) { + return function getAbsoluteUrl({ hash = '', path = '/app/kibana', search = '' } = {}) { return url.format({ protocol, hostname, diff --git a/x-pack/plugins/reporting/server/export_types/common/get_full_urls.ts b/x-pack/plugins/reporting/server/export_types/common/get_full_urls.ts index 06c1766f948ff2..f4e3a7b723c088 100644 --- a/x-pack/plugins/reporting/server/export_types/common/get_full_urls.ts +++ b/x-pack/plugins/reporting/server/export_types/common/get_full_urls.ts @@ -36,12 +36,7 @@ export function getFullUrls({ config.get('kibanaServer', 'hostname'), config.get('kibanaServer', 'port'), ] as string[]; - const getAbsoluteUrl = getAbsoluteUrlFactory({ - defaultBasePath: basePath, - protocol, - hostname, - port, - }); + const getAbsoluteUrl = getAbsoluteUrlFactory({ basePath, protocol, hostname, port }); // PDF and PNG job params put in the url differently let relativeUrls: string[] = []; diff --git a/x-pack/plugins/reporting/server/routes/diagnostic/screenshot.ts b/x-pack/plugins/reporting/server/routes/diagnostic/screenshot.ts index 979283f9f037c3..0acf384869dedb 100644 --- a/x-pack/plugins/reporting/server/routes/diagnostic/screenshot.ts +++ b/x-pack/plugins/reporting/server/routes/diagnostic/screenshot.ts @@ -35,19 +35,8 @@ export const registerDiagnoseScreenshot = (reporting: ReportingCore, logger: Log config.get('kibanaServer', 'port'), ] as string[]; - const getAbsoluteUrl = getAbsoluteUrlFactory({ - defaultBasePath: basePath, - protocol, - hostname, - port, - }); - - const hashUrl = getAbsoluteUrl({ - basePath, - path: '/', - hash: '', - search: '', - }); + const getAbsoluteUrl = getAbsoluteUrlFactory({ basePath, protocol, hostname, port }); + const hashUrl = getAbsoluteUrl({ path: '/', hash: '', search: '' }); // Hack the layout to make the base/login page work const layout = {