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

* remove whitespace replace

* readd replace newline

* adding a test
This commit is contained in:
Peter Holmberg
2020-02-13 11:32:18 +01:00
committed by GitHub
parent 0d5c1e1bc7
commit e5df200893
2 changed files with 35 additions and 1 deletions

View File

@@ -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,

View File

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