From c7bb44b34a73a8a5f82d8cc365ace7a0dd8f450f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 12 Sep 2018 13:13:47 +0200 Subject: [PATCH] fix: url update loop fix (#13243) --- public/app/core/specs/url.test.ts | 16 ++++++++++++++++ public/app/core/utils/url.ts | 4 +--- 2 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 public/app/core/specs/url.test.ts diff --git a/public/app/core/specs/url.test.ts b/public/app/core/specs/url.test.ts new file mode 100644 index 00000000000..b5994488128 --- /dev/null +++ b/public/app/core/specs/url.test.ts @@ -0,0 +1,16 @@ +import { toUrlParams } from '../utils/url'; + +describe('toUrlParams', () => { + it('should encode object properties as url parameters', () => { + const url = toUrlParams({ + server: 'backend-01', + hasSpace: 'has space', + many: ['1', '2', '3'], + true: true, + number: 20, + isNull: null, + isUndefined: undefined, + }); + expect(url).toBe('server=backend-01&hasSpace=has%20space&many=1&many=2&many=3&true&number=20&isNull=&isUndefined='); + }); +}); diff --git a/public/app/core/utils/url.ts b/public/app/core/utils/url.ts index 04c3e9a4308..198029b0e9f 100644 --- a/public/app/core/utils/url.ts +++ b/public/app/core/utils/url.ts @@ -50,7 +50,5 @@ export function toUrlParams(a) { return s; }; - return buildParams('', a) - .join('&') - .replace(/%20/g, '+'); + return buildParams('', a).join('&'); }