Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert substr() to substring() #6954

Merged
merged 4 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/components/error_boundary/error_boundary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ export class EuiErrorBoundary extends Component<
// For consistency, rebuild the full error text from the Error subparts.
const { message, stack } = error;
const idx = stack?.indexOf(message) || -1;
const stackStr = idx > -1 ? stack?.substr(idx + message.length + 1) : stack;
const stackStr =
idx > -1 ? stack?.substring(idx + message.length + 1) : stack;
const errorMessage = `Error: ${message}
${stackStr}`;
this.setState({
Expand Down
11 changes: 7 additions & 4 deletions src/components/highlight/highlight.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const highlight = (
<Fragment>
{chunks.map((chunk) => {
const { end, highlight, start } = chunk;
const value = searchSubject.substr(start, end - start);
const value = searchSubject.substring(start, end);
if (highlight) {
return (
<EuiMark
Expand Down Expand Up @@ -103,9 +103,12 @@ const highlight = (
return searchSubject;
}

const preMatch: string = searchSubject.substr(0, indexOfMatch);
const match: string = searchSubject.substr(indexOfMatch, searchValue.length);
const postMatch: string = searchSubject.substr(
const preMatch: string = searchSubject.substring(0, indexOfMatch);
const match: string = searchSubject.substring(
indexOfMatch,
indexOfMatch + searchValue.length
);
const postMatch: string = searchSubject.substring(
indexOfMatch + searchValue.length
);

Expand Down
4 changes: 2 additions & 2 deletions src/components/markdown_editor/markdown_editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ export const EuiMarkdownEditor = forwardRef<

const replaceNode = useCallback(
(position, next) => {
const leading = value.substr(0, position.start.offset);
const trailing = value.substr(position.end.offset);
const leading = value.substring(0, position.start.offset);
const trailing = value.substring(position.end.offset);
onChange(`${leading}${next}${trailing}`);
},
[value, onChange]
Expand Down
2 changes: 2 additions & 0 deletions upcoming_changelogs/6954.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Updated deprecated `.substr()` usages to `.substring()`