Skip to content

Commit

Permalink
remove scoped static assets path
Browse files Browse the repository at this point in the history
  • Loading branch information
jloleysens committed Oct 19, 2023
1 parent a9fe5fa commit 8b68ba3
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import { StaticAssets } from './static_assets';
import { BasePath } from './base_path_service';
import { CdnConfig } from './cdn';
import { mockRouter } from '@kbn/core-http-router-server-mocks';

describe('StaticAssets', () => {
let basePath: BasePath;
Expand All @@ -24,12 +23,6 @@ describe('StaticAssets', () => {
expect(staticAssets.getHrefBase()).toEqual('/test');
});

it('can be scoped with Kibana request', () => {
const req = mockRouter.createKibanaRequest();
basePath.set(req, '/my-space');
expect(staticAssets.getHrefBase(req)).toEqual('/test/my-space');
});

it('provides the correct HREF given a CDN is configured', () => {
cdnConfig = CdnConfig.from({ url: 'https://cdn.example.com/test' });
staticAssets = new StaticAssets(basePath, cdnConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
* Side Public License, v 1.
*/

import type { KibanaRequest } from '@kbn/core-http-server/src/router';
import type { BasePath } from './base_path_service';
import { CdnConfig } from './cdn';

export interface IStaticAssets {
getHrefBase(request?: KibanaRequest): string;
getHrefBase(): string;
}

export class StaticAssets implements IStaticAssets {
Expand All @@ -20,14 +19,10 @@ export class StaticAssets implements IStaticAssets {
* Returns a href (hypertext reference) intended to be used as the base for constructing
* other hrefs to static assets.
*/
getHrefBase(request?: KibanaRequest): string {
getHrefBase(): string {
if (this.cdnConfig.baseHref) {
return this.cdnConfig.baseHref;
}
// TODO: not sure if this is necessary for static asset HREFs.
if (request) {
return this.basePath.get(request);
}
return this.basePath.serverBasePath;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export class RenderingService {
packageInfo: this.coreContext.env.packageInfo,
};
const buildNum = env.packageInfo.buildNum;
const staticAssetsHrefBase = http.staticAssets.getHrefBase(request);
const staticAssetsHrefBase = http.staticAssets.getHrefBase();
const basePath = http.basePath.get(request);
const { serverBasePath, publicBaseUrl } = http.basePath;

Expand Down

0 comments on commit 8b68ba3

Please sign in to comment.