mirror of
https://github.com/usebruno/bruno.git
synced 2024-12-22 14:41:04 +01:00
fix: fixed issue while deleting empty query params (#93)
This commit is contained in:
parent
8044286b80
commit
f22858219b
@ -50,7 +50,6 @@
|
||||
"react-redux": "^7.2.6",
|
||||
"react-tooltip": "^5.5.2",
|
||||
"sass": "^1.46.0",
|
||||
"split-on-first": "^3.0.0",
|
||||
"styled-components": "^5.3.3",
|
||||
"tailwindcss": "^2.2.19",
|
||||
"yup": "^0.32.11"
|
||||
|
@ -102,7 +102,7 @@ class SingleLineEditor extends Component {
|
||||
}
|
||||
if (this.props.value !== prevProps.value && this.props.value !== this.cachedValue && this.editor) {
|
||||
this.cachedValue = this.props.value;
|
||||
this.editor.setValue(this.props.value);
|
||||
this.editor.setValue(this.props.value || '');
|
||||
}
|
||||
this.ignoreChangeEvent = false;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import filter from 'lodash/filter';
|
||||
import each from 'lodash/each';
|
||||
import cloneDeep from 'lodash/cloneDeep';
|
||||
import { createSlice } from '@reduxjs/toolkit';
|
||||
import splitOnFirst from 'split-on-first';
|
||||
import { splitOnFirst } from 'utils/url';
|
||||
import {
|
||||
findCollectionByUid,
|
||||
findCollectionByPathname,
|
||||
|
@ -40,3 +40,16 @@ export const stringifyQueryParams = (params) => {
|
||||
|
||||
return queryString.join('&');
|
||||
};
|
||||
|
||||
export const splitOnFirst = (str, char) => {
|
||||
if(!str || !str.length) {
|
||||
return [str];
|
||||
}
|
||||
|
||||
let index = str.indexOf(char);
|
||||
if (index === -1) {
|
||||
return [str];
|
||||
}
|
||||
|
||||
return [str.slice(0, index), str.slice(index + 1)];
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { parseQueryParams } from './index';
|
||||
import { parseQueryParams, splitOnFirst } from './index';
|
||||
|
||||
describe('Url Utils - parseQueryParams', () => {
|
||||
it('should parse query - case 1', () => {
|
||||
@ -41,3 +41,30 @@ describe('Url Utils - parseQueryParams', () => {
|
||||
expect(params).toEqual([{name: 'a', value: '1'}, {name: 'b', value: '2'}]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Url Utils - splitOnFirst', () => {
|
||||
it('should split on first - case 1', () => {
|
||||
const params = splitOnFirst("a", "=");
|
||||
expect(params).toEqual(['a']);
|
||||
});
|
||||
|
||||
it('should split on first - case 2', () => {
|
||||
const params = splitOnFirst("a=", "=");
|
||||
expect(params).toEqual(['a', '']);
|
||||
});
|
||||
|
||||
it('should split on first - case 3', () => {
|
||||
const params = splitOnFirst("a=1", "=");
|
||||
expect(params).toEqual(['a', '1']);
|
||||
});
|
||||
|
||||
it('should split on first - case 4', () => {
|
||||
const params = splitOnFirst("a=1&b=2", "=");
|
||||
expect(params).toEqual(['a', '1&b=2']);
|
||||
});
|
||||
|
||||
it('should split on first - case 5', () => {
|
||||
const params = splitOnFirst("a=1&b=2", "&");
|
||||
expect(params).toEqual(['a=1', 'b=2']);
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user