mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Fix: Do not remove whitespace in PanelLink url (#22087)
* remove whitespace replace * readd replace newline * adding a test
This commit is contained in:
@@ -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', () => {
|
||||
|
||||
Reference in New Issue
Block a user