Преглед на файлове

fix: url update loop fix (#13243)

Torkel Ödegaard преди 7 години
родител
ревизия
c7bb44b34a
променени са 2 файла, в които са добавени 17 реда и са изтрити 3 реда
  1. 16 0
      public/app/core/specs/url.test.ts
  2. 1 3
      public/app/core/utils/url.ts

+ 16 - 0
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=');
+  });
+});

+ 1 - 3
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('&');
 }