mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
* remove "deprecated: " from console warning * refactor "deprecation" to "warning" * complete name refactor in test files
This commit is contained in:
parent
088525c003
commit
be49344385
3 changed files with 21 additions and 21 deletions
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { extractDeprecationMessages } from '../../../lib/utils';
|
||||
import { extractWarningMessages } from '../../../lib/utils';
|
||||
import { XJson } from '../../../../../es_ui_shared/public';
|
||||
const { collapseLiteralStrings } = XJson;
|
||||
// @ts-ignore
|
||||
|
@ -88,8 +88,8 @@ export function sendRequestToES(args: EsRequestArgs): Promise<ESRequestResult[]>
|
|||
|
||||
const warnings = xhr.getResponseHeader('warning');
|
||||
if (warnings) {
|
||||
const deprecationMessages = extractDeprecationMessages(warnings);
|
||||
value = deprecationMessages.join('\n') + '\n' + value;
|
||||
const warningMessages = extractWarningMessages(warnings);
|
||||
value = warningMessages.join('\n') + '\n' + value;
|
||||
}
|
||||
|
||||
if (isMultiRequest) {
|
||||
|
|
|
@ -48,14 +48,14 @@ export function formatRequestBodyDoc(data: string[], indent: boolean) {
|
|||
};
|
||||
}
|
||||
|
||||
export function extractDeprecationMessages(warnings: string) {
|
||||
export function extractWarningMessages(warnings: string) {
|
||||
// pattern for valid warning header
|
||||
const re = /\d{3} [0-9a-zA-Z!#$%&'*+-.^_`|~]+ \"((?:\t| |!|[\x23-\x5b]|[\x5d-\x7e]|[\x80-\xff]|\\\\|\\")*)\"(?: \"[^"]*\")?/;
|
||||
// split on any comma that is followed by an even number of quotes
|
||||
return _.map(splitOnUnquotedCommaSpace(warnings), (warning) => {
|
||||
const match = re.exec(warning);
|
||||
// extract the actual warning if there was a match
|
||||
return '#! Deprecation: ' + (match !== null ? unescape(match[1]) : warning);
|
||||
return '#! ' + (match !== null ? unescape(match[1]) : warning);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -11,51 +11,51 @@ import * as utils from '.';
|
|||
describe('Utils class', () => {
|
||||
test('extract deprecation messages', function () {
|
||||
expect(
|
||||
utils.extractDeprecationMessages(
|
||||
utils.extractWarningMessages(
|
||||
'299 Elasticsearch-6.0.0-alpha1-SNAPSHOT-abcdef1 "this is a warning" "Mon, 27 Feb 2017 14:52:14 GMT"'
|
||||
)
|
||||
).toEqual(['#! Deprecation: this is a warning']);
|
||||
).toEqual(['#! this is a warning']);
|
||||
expect(
|
||||
utils.extractDeprecationMessages(
|
||||
utils.extractWarningMessages(
|
||||
'299 Elasticsearch-6.0.0-alpha1-SNAPSHOT-abcdef1 "this is a warning"'
|
||||
)
|
||||
).toEqual(['#! Deprecation: this is a warning']);
|
||||
).toEqual(['#! this is a warning']);
|
||||
|
||||
expect(
|
||||
utils.extractDeprecationMessages(
|
||||
utils.extractWarningMessages(
|
||||
'299 Elasticsearch-6.0.0-alpha1-SNAPSHOT-abcdef1 "this is a warning" "Mon, 27 Feb 2017 14:52:14 GMT", 299 Elasticsearch-6.0.0-alpha1-SNAPSHOT-abcdef1 "this is a second warning" "Mon, 27 Feb 2017 14:52:14 GMT"'
|
||||
)
|
||||
).toEqual(['#! Deprecation: this is a warning', '#! Deprecation: this is a second warning']);
|
||||
).toEqual(['#! this is a warning', '#! this is a second warning']);
|
||||
expect(
|
||||
utils.extractDeprecationMessages(
|
||||
utils.extractWarningMessages(
|
||||
'299 Elasticsearch-6.0.0-alpha1-SNAPSHOT-abcdef1 "this is a warning", 299 Elasticsearch-6.0.0-alpha1-SNAPSHOT-abcdef1 "this is a second warning"'
|
||||
)
|
||||
).toEqual(['#! Deprecation: this is a warning', '#! Deprecation: this is a second warning']);
|
||||
).toEqual(['#! this is a warning', '#! this is a second warning']);
|
||||
|
||||
expect(
|
||||
utils.extractDeprecationMessages(
|
||||
utils.extractWarningMessages(
|
||||
'299 Elasticsearch-6.0.0-alpha1-SNAPSHOT-abcdef1 "this is a warning, and it includes a comma" "Mon, 27 Feb 2017 14:52:14 GMT"'
|
||||
)
|
||||
).toEqual(['#! Deprecation: this is a warning, and it includes a comma']);
|
||||
).toEqual(['#! this is a warning, and it includes a comma']);
|
||||
expect(
|
||||
utils.extractDeprecationMessages(
|
||||
utils.extractWarningMessages(
|
||||
'299 Elasticsearch-6.0.0-alpha1-SNAPSHOT-abcdef1 "this is a warning, and it includes a comma"'
|
||||
)
|
||||
).toEqual(['#! Deprecation: this is a warning, and it includes a comma']);
|
||||
).toEqual(['#! this is a warning, and it includes a comma']);
|
||||
|
||||
expect(
|
||||
utils.extractDeprecationMessages(
|
||||
utils.extractWarningMessages(
|
||||
'299 Elasticsearch-6.0.0-alpha1-SNAPSHOT-abcdef1 "this is a warning, and it includes an escaped backslash \\\\ and a pair of \\"escaped quotes\\"" "Mon, 27 Feb 2017 14:52:14 GMT"'
|
||||
)
|
||||
).toEqual([
|
||||
'#! Deprecation: this is a warning, and it includes an escaped backslash \\ and a pair of "escaped quotes"',
|
||||
'#! this is a warning, and it includes an escaped backslash \\ and a pair of "escaped quotes"',
|
||||
]);
|
||||
expect(
|
||||
utils.extractDeprecationMessages(
|
||||
utils.extractWarningMessages(
|
||||
'299 Elasticsearch-6.0.0-alpha1-SNAPSHOT-abcdef1 "this is a warning, and it includes an escaped backslash \\\\ and a pair of \\"escaped quotes\\""'
|
||||
)
|
||||
).toEqual([
|
||||
'#! Deprecation: this is a warning, and it includes an escaped backslash \\ and a pair of "escaped quotes"',
|
||||
'#! this is a warning, and it includes an escaped backslash \\ and a pair of "escaped quotes"',
|
||||
]);
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue