Fix: Do not remove whitespace in PanelLink url (#22087)

* remove whitespace replace

* readd replace newline

* adding a test
pull/21514/head
Peter Holmberg 5 years ago committed by GitHub
parent 0d5c1e1bc7
commit e5df200893
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      public/app/features/panel/panellinks/link_srv.ts
  2. 34
      public/app/features/panel/panellinks/specs/link_srv.test.ts

@ -283,7 +283,7 @@ export class LinkSrv implements LinkService {
}
const info: LinkModel<T> = {
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,

@ -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', () => {

Loading…
Cancel
Save