diff --git a/public/app/features/panel/panellinks/link_srv.ts b/public/app/features/panel/panellinks/link_srv.ts index b24437366c6..a76eb6daefc 100644 --- a/public/app/features/panel/panellinks/link_srv.ts +++ b/public/app/features/panel/panellinks/link_srv.ts @@ -283,7 +283,7 @@ export class LinkSrv implements LinkService { } const info: LinkModel = { - href: locationUtil.assureBaseUrl(href.replace(/\s|\n/g, '')), + href: locationUtil.assureBaseUrl(href.replace(/\n/g, '')), title: this.templateSrv.replace(link.title || '', scopedVars), target: link.targetBlank ? '_blank' : '_self', origin, diff --git a/public/app/features/panel/panellinks/specs/link_srv.test.ts b/public/app/features/panel/panellinks/specs/link_srv.test.ts index a5f65c264fc..242959f347c 100644 --- a/public/app/features/panel/panellinks/specs/link_srv.test.ts +++ b/public/app/features/panel/panellinks/specs/link_srv.test.ts @@ -142,6 +142,40 @@ describe('linkSrv', () => { ).href ).toEqual('/d/1?time=1000000001'); }); + it('should not trim white space from data links', () => { + expect( + linkSrv.getDataLinkUIModel( + { + title: 'White space', + url: 'www.google.com?query=some query', + }, + { + __value: { + value: { time: dataPointMock.datapoint[0] }, + text: 'Value', + }, + }, + {} + ).href + ).toEqual('www.google.com?query=some query'); + }); + it('should remove new lines from data link', () => { + expect( + linkSrv.getDataLinkUIModel( + { + title: 'New line', + url: 'www.google.com?query=some\nquery', + }, + { + __value: { + value: { time: dataPointMock.datapoint[0] }, + text: 'Value', + }, + }, + {} + ).href + ).toEqual('www.google.com?query=somequery'); + }); }); describe('sanitization', () => {