Skip to content

Commit

Permalink
[Discover] mailto links in data view urls (elastic#200070)
Browse files Browse the repository at this point in the history
Adds `mailto:` as an allowed URL Url formatters in data views.
  • Loading branch information
ghudgins authored and wayneseymour committed Nov 18, 2024
1 parent 9c63452 commit 62e9fe7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/plugins/field_formats/common/converters/url.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ describe('UrlFormat', () => {
);
});

test('outputs a mailto: link when URL starts with mailto:', () => {
const url = new UrlFormat({});

expect(url.convert('mailto:[email protected]', HTML_CONTEXT_TYPE)).toBe(
'<a href="mailto:[email protected]" target="_blank" rel="noopener noreferrer">mailto:[email protected]</a>'
);
});

test('outputs an <audio> if type === "audio"', () => {
const url = new UrlFormat({ type: 'audio' });

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/field_formats/common/converters/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
} from '../types';

const templateMatchRE = /{{([\s\S]+?)}}/g;
const allowedUrlSchemes = ['http://', 'https://'];
const allowedUrlSchemes = ['http://', 'https://', 'mailto:'];

const URL_TYPES = [
{
Expand Down

0 comments on commit 62e9fe7

Please sign in to comment.