Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.5] Fix for URL field formatter not able to render relative URLs properly. #55702

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/legacy/core_plugins/kibana/common/field_formats/types/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ export function createUrlFormat() {
const url = escape(this.formatUrl(rawValue));
const label = escape(this.formatLabel(rawValue, url));

if (!parsedUrl) {
parsedUrl = UrlFormat.defaultParsedUrl;
}

switch (this.param('type')) {
case 'audio':
return `<audio controls preload="none" src="${url}">`;
Expand Down Expand Up @@ -201,5 +205,24 @@ export function createUrlFormat() {
};
}

async function initializeDefaultParsedUrl() {
if (UrlFormat.defaultParsedUrl !== undefined) {
return;
}

try {
const platform = await import('ui/new_platform');
UrlFormat.defaultParsedUrl = {
origin: global.window.location.origin,
pathname: global.window.location.pathname,
basePath: platform.npSetup.core.http.basePath.get(),
};
} catch (err) {
UrlFormat.defaultParsedUrl = null;
}
}

initializeDefaultParsedUrl();

return UrlFormat;
}