mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
* [Enterprise Search] Add parseQueryParams helper This PR migrates part of the ent-search queryParams util, `parseQueryParams` for use in Workplace Search. `setQueryParams` was no a part of this PR because it is only used one time in App Search and a better alternative might be available for that use-case * Remove mock * Actually test functionality of query-string * Add test for array * Better test name
This commit is contained in:
parent
064fd8ef84
commit
02706ffaf4
3 changed files with 31 additions and 0 deletions
|
@ -0,0 +1,7 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
export { parseQueryParams } from './query_params';
|
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { parseQueryParams } from './';
|
||||
|
||||
describe('parseQueryParams', () => {
|
||||
it('parse query strings', () => {
|
||||
expect(parseQueryParams('?foo=bar')).toEqual({ foo: 'bar' });
|
||||
expect(parseQueryParams('?foo[]=bar&foo[]=baz')).toEqual({ foo: ['bar', 'baz'] });
|
||||
});
|
||||
});
|
|
@ -0,0 +1,10 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import queryString from 'query-string';
|
||||
|
||||
export const parseQueryParams = (search: string) =>
|
||||
queryString.parse(search, { arrayFormat: 'bracket' });
|
Loading…
Add table
Add a link
Reference in a new issue