mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
# Backport This will backport the following commits from `main` to `8.x`: - [[data views] Remove regex for creating dot notation (#193795)](https://github.com/elastic/kibana/pull/193795) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Matthew Kime","email":"matt@mattki.me"},"sourceCommit":{"committedDate":"2024-09-24T00:30:52Z","message":"[data views] Remove regex for creating dot notation (#193795)\n\n## Summary\r\n\r\nUse basic string and array functions instead of regex to create short\r\ndot field names.","sha":"ab9459ca4358451614c3b4fb09380af9841e7a66","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Data Views","release_note:skip","v9.0.0","Team:DataDiscovery","backport:all-open"],"title":"[data views] Remove regex for creating dot notation","number":193795,"url":"https://github.com/elastic/kibana/pull/193795","mergeCommit":{"message":"[data views] Remove regex for creating dot notation (#193795)\n\n## Summary\r\n\r\nUse basic string and array functions instead of regex to create short\r\ndot field names.","sha":"ab9459ca4358451614c3b4fb09380af9841e7a66"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/193795","number":193795,"mergeCommit":{"message":"[data views] Remove regex for creating dot notation (#193795)\n\n## Summary\r\n\r\nUse basic string and array functions instead of regex to create short\r\ndot field names.","sha":"ab9459ca4358451614c3b4fb09380af9841e7a66"}}]}] BACKPORT--> Co-authored-by: Matthew Kime <matt@mattki.me>
This commit is contained in:
parent
93ec7be2d4
commit
87ac87ad71
1 changed files with 11 additions and 3 deletions
|
@ -26,14 +26,22 @@ export const isMultiField = isDataViewFieldSubtypeMulti;
|
|||
export const getFieldSubtypeMulti = getDataViewFieldSubtypeMulti;
|
||||
export const getFieldSubtypeNested = getDataViewFieldSubtypeNested;
|
||||
|
||||
const DOT_PREFIX_RE = /(.).+?\./g;
|
||||
|
||||
/**
|
||||
* Convert a dot.notated.string into a short
|
||||
* version (d.n.string)
|
||||
*/
|
||||
export function shortenDottedString(input: string): string {
|
||||
return typeof input !== 'string' ? input : input.replace(DOT_PREFIX_RE, '$1.');
|
||||
if (typeof input === 'string') {
|
||||
const split = input.split('.');
|
||||
return split.reduce((acc, part, i) => {
|
||||
if (i === split.length - 1) {
|
||||
return acc + part;
|
||||
}
|
||||
return acc + part[0] + '.';
|
||||
}, '');
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
// Note - this code is duplicated from @kbn/es-query
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue