Skip to content

Commit

Permalink
Downgrade to query-string v5.1.1 (#59633) (#60107)
Browse files Browse the repository at this point in the history
* Downgrade to query-string v5.1.1

* update lib version for x-pack

* fix JEST

* fix functional tests

Co-authored-by: Elastic Machine <[email protected]>

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
alexwizp and elasticmachine authored Mar 13, 2020
1 parent a549d9d commit 2371926
Show file tree
Hide file tree
Showing 11 changed files with 141 additions and 35 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@
"prop-types": "15.6.0",
"proxy-from-env": "1.0.0",
"pug": "^2.0.4",
"query-string": "6.10.1",
"query-string": "5.1.1",
"raw-loader": "3.1.0",
"react": "^16.12.0",
"react-color": "^2.13.8",
Expand Down
46 changes: 46 additions & 0 deletions test/typings/query_string.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

declare module 'query-string' {
type ArrayFormat = 'bracket' | 'index' | 'none';

export interface ParseOptions {
arrayFormat?: ArrayFormat;
sort: ((itemLeft: string, itemRight: string) => number) | false;
}

export interface ParsedQuery<T = string> {
[key: string]: T | T[] | null | undefined;
}

export function parse(str: string, options?: ParseOptions): ParsedQuery;

export function parseUrl(str: string, options?: ParseOptions): { url: string; query: any };

export interface StringifyOptions {
strict?: boolean;
encode?: boolean;
arrayFormat?: ArrayFormat;
sort: ((itemLeft: string, itemRight: string) => number) | false;
}

export function stringify(obj: object, options?: StringifyOptions): string;

export function extract(str: string): string;
}
46 changes: 46 additions & 0 deletions typings/query_string.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

declare module 'query-string' {
type ArrayFormat = 'bracket' | 'index' | 'none';

export interface ParseOptions {
arrayFormat?: ArrayFormat;
sort: ((itemLeft: string, itemRight: string) => number) | false;
}

export interface ParsedQuery<T = string> {
[key: string]: T | T[] | null | undefined;
}

export function parse(str: string, options?: ParseOptions): ParsedQuery;

export function parseUrl(str: string, options?: ParseOptions): { url: string; query: any };

export interface StringifyOptions {
strict?: boolean;
encode?: boolean;
arrayFormat?: ArrayFormat;
sort: ((itemLeft: string, itemRight: string) => number) | false;
}

export function stringify(obj: object, options?: StringifyOptions): string;

export function extract(str: string): string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ describe('fromQuery and toQuery', () => {
expect(
fromQuery(
toQuery(
'?name=john%20doe&rangeFrom=2019-03-03T12:00:00.000Z&path=a%2Fb'
'?name=john%20doe&path=a%2Fb&rangeFrom=2019-03-03T12:00:00.000Z'
)
)
).toEqual('name=john%20doe&rangeFrom=2019-03-03T12:00:00.000Z&path=a%2Fb');
).toEqual('name=john%20doe&path=a%2Fb&rangeFrom=2019-03-03T12:00:00.000Z');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ describe('useUrlParams', () => {

expect(history.push).toHaveBeenCalledWith({
pathname: '/',
search: 'g=%22%22&dateRangeStart=now-12&dateRangeEnd=now',
search: 'dateRangeEnd=now&dateRangeStart=now-12&g=%22%22',
});
});
});
2 changes: 1 addition & 1 deletion x-pack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@
"proper-lockfile": "^3.2.0",
"puid": "1.0.7",
"puppeteer-core": "^1.19.0",
"query-string": "6.10.1",
"query-string": "5.1.1",
"raw-loader": "3.1.0",
"re-resizable": "^6.1.1",
"react": "^16.12.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('RedirectToLogs component', () => {

expect(component).toMatchInlineSnapshot(`
<Redirect
to="/stream?sourceId=default&logPosition=(position:(tiebreaker:0,time:1550671089404),streamLive:!f)&logFilter=(expression:'',kind:kuery)"
to="/stream?logPosition=(position:(tiebreaker:0,time:1550671089404),streamLive:!f)&sourceId=default&logFilter=(expression:'',kind:kuery)"
/>
`);
});
Expand All @@ -33,7 +33,7 @@ describe('RedirectToLogs component', () => {

expect(component).toMatchInlineSnapshot(`
<Redirect
to="/stream?sourceId=default&logPosition=(position:(tiebreaker:0,time:1550671089404),streamLive:!f)&logFilter=(expression:'FILTER_FIELD:FILTER_VALUE',kind:kuery)"
to="/stream?logPosition=(position:(tiebreaker:0,time:1550671089404),streamLive:!f)&sourceId=default&logFilter=(expression:'FILTER_FIELD:FILTER_VALUE',kind:kuery)"
/>
`);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe('RedirectToNodeLogs component', () => {

expect(component).toMatchInlineSnapshot(`
<Redirect
to="/?sourceId=default&logPosition=(position:(tiebreaker:0,time:1550671089404),streamLive:!f)&logFilter=(expression:'HOST_FIELD:%20HOST_NAME',kind:kuery)"
to="/?logPosition=(position:(tiebreaker:0,time:1550671089404),streamLive:!f)&sourceId=default&logFilter=(expression:'HOST_FIELD:%20HOST_NAME',kind:kuery)"
/>
`);
});
Expand All @@ -89,7 +89,7 @@ describe('RedirectToNodeLogs component', () => {

expect(component).toMatchInlineSnapshot(`
<Redirect
to="/?sourceId=default&logPosition=(position:(tiebreaker:0,time:1550671089404),streamLive:!f)&logFilter=(expression:'(HOST_FIELD:%20HOST_NAME)%20and%20(FILTER_FIELD:FILTER_VALUE)',kind:kuery)"
to="/?logPosition=(position:(tiebreaker:0,time:1550671089404),streamLive:!f)&sourceId=default&logFilter=(expression:'(HOST_FIELD:%20HOST_NAME)%20and%20(FILTER_FIELD:FILTER_VALUE)',kind:kuery)"
/>
`);
});
Expand Down
2 changes: 1 addition & 1 deletion x-pack/test/functional/apps/infra/link_to.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
state: undefined,
};
const expectedSearchString =
"sourceId=default&logPosition=(position:(tiebreaker:0,time:1565707203194),streamLive:!f)&logFilter=(expression:'trace.id:433b4651687e18be2c6c8e3b11f53d09',kind:kuery)";
"logFilter=(expression:'trace.id:433b4651687e18be2c6c8e3b11f53d09',kind:kuery)&logPosition=(position:(tiebreaker:0,time:1565707203194),streamLive:!f)&sourceId=default";
const expectedRedirectPath = '/logs/stream?';

await pageObjects.common.navigateToUrlWithBrowserHistory(
Expand Down
33 changes: 33 additions & 0 deletions x-pack/typings/query_string.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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.
*/

declare module 'query-string' {
type ArrayFormat = 'bracket' | 'index' | 'none';

export interface ParseOptions {
arrayFormat?: ArrayFormat;
sort?: ((itemLeft: string, itemRight: string) => number) | false;
}

export interface ParsedQuery<T = string> {
[key: string]: T | T[] | null | undefined;
}

export function parse(str: string, options?: ParseOptions): ParsedQuery;

export function parseUrl(str: string, options?: ParseOptions): { url: string; query: any };

export interface StringifyOptions {
strict?: boolean;
encode?: boolean;
arrayFormat?: ArrayFormat;
sort?: ((itemLeft: string, itemRight: string) => number) | false;
}

export function stringify(obj: object, options?: StringifyOptions): string;

export function extract(str: string): string;
}
31 changes: 6 additions & 25 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -24656,14 +24656,14 @@ qs@~6.4.0:
resolved "https://registry.yarnpkg.com/qs/-/qs-6.4.0.tgz#13e26d28ad6b0ffaa91312cd3bf708ed351e7233"
integrity sha1-E+JtKK1rD/qpExLNO/cI7TUecjM=

query-string@6.10.1:
version "6.10.1"
resolved "https://registry.yarnpkg.com/query-string/-/query-string-6.10.1.tgz#30b3505f6fca741d5ae541964d1b3ae9dc2a0de8"
integrity sha512-SHTUV6gDlgMXg/AQUuLpTiBtW/etZ9JT6k6RCtCyqADquApLX0Aq5oK/s5UeTUAWBG50IExjIr587GqfXRfM4A==
query-string@5.1.1, query-string@^5.0.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/query-string/-/query-string-5.1.1.tgz#a78c012b71c17e05f2e3fa2319dd330682efb3cb"
integrity sha512-gjWOsm2SoGlgLEdAGt7a6slVOk9mGiXmPFMqrEhLQ68rhQuBnpfs3+EmlvqKyxnCo9/PPlF+9MtY02S1aFg+Jw==
dependencies:
decode-uri-component "^0.2.0"
split-on-first "^1.0.0"
strict-uri-encode "^2.0.0"
object-assign "^4.1.0"
strict-uri-encode "^1.0.0"

query-string@^4.1.0, query-string@^4.2.2:
version "4.3.4"
Expand All @@ -24673,15 +24673,6 @@ query-string@^4.1.0, query-string@^4.2.2:
object-assign "^4.1.0"
strict-uri-encode "^1.0.0"

query-string@^5.0.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/query-string/-/query-string-5.1.1.tgz#a78c012b71c17e05f2e3fa2319dd330682efb3cb"
integrity sha512-gjWOsm2SoGlgLEdAGt7a6slVOk9mGiXmPFMqrEhLQ68rhQuBnpfs3+EmlvqKyxnCo9/PPlF+9MtY02S1aFg+Jw==
dependencies:
decode-uri-component "^0.2.0"
object-assign "^4.1.0"
strict-uri-encode "^1.0.0"

querystring-es3@^0.2.0:
version "0.2.1"
resolved "https://registry.yarnpkg.com/querystring-es3/-/querystring-es3-0.2.1.tgz#9ec61f79049875707d69414596fd907a4d711e73"
Expand Down Expand Up @@ -28281,11 +28272,6 @@ spdy@^4.0.1:
select-hose "^2.0.0"
spdy-transport "^3.0.0"

split-on-first@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/split-on-first/-/split-on-first-1.1.0.tgz#f610afeee3b12bce1d0c30425e76398b78249a5f"
integrity sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw==

split-string@^3.0.1, split-string@^3.0.2:
version "3.1.0"
resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2"
Expand Down Expand Up @@ -28589,11 +28575,6 @@ strict-uri-encode@^1.0.0:
resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz#279b225df1d582b1f54e65addd4352e18faa0713"
integrity sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM=

strict-uri-encode@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz#b9c7330c7042862f6b142dc274bbcc5866ce3546"
integrity sha1-ucczDHBChi9rFC3CdLvMWGbONUY=

string-length@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/string-length/-/string-length-1.0.1.tgz#56970fb1c38558e9e70b728bf3de269ac45adfac"
Expand Down

0 comments on commit 2371926

Please sign in to comment.