[ZEPPELIN-6473] Replace deprecated substr() with slice() in note-create#5305
Open
kimyenac wants to merge 1 commit into
Open
[ZEPPELIN-6473] Replace deprecated substr() with slice() in note-create#5305kimyenac wants to merge 1 commit into
kimyenac wants to merge 1 commit into
Conversation
Migrate the three String.prototype.substr() calls in note-create.component.ts to slice(). substr() is a legacy Annex B API the spec recommends against. All replacements preserve current behavior: - newNoteName(): substr(15) -> slice(15) (single-arg, runs to end) - cloneNoteName(): substr(0, lastIndex) -> slice(0, lastIndex) (equivalent because start is 0, so length == end index) - cloneNoteName(): substr(lastIndex) -> slice(lastIndex) (single-arg) Verified via npm run lint and npm run build:angular.
voidmatcha
requested changes
Jul 15, 2026
voidmatcha
left a comment
Member
There was a problem hiding this comment.
The note-create changes look behavior-preserving to me.
One small scope suggestion: although ZEPPELIN-6473 was filed around note-create, if this PR is intended as a New UI substr() cleanup, it may be worth replacing the remaining Angular UI usage as well:
const dotIndex = _callbackStr.indexOf('.');
const callback = dotIndex !== -1 ? _callbackStr.slice(0, dotIndex) : null;This keeps the existing behavior while avoiding the deprecated substr() call.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is this PR for?
The New UI note-create dialog generates note names using
String.prototype.substr(), an Annex B (legacy) API the language spec recommends against and flags for eventual removal. This PR migrates the threesubstr()calls innote-create.component.tsto the recommendedslice().The two methods are not blindly interchangeable —
substr(start, length)takes a length, whileslice(start, end)takes an end index — so each call site was checked individually to confirm behavior is preserved:newNoteName():substr(15)→slice(15)— single-arg, runs to end of string (equivalent).cloneNoteName():substr(0, lastIndex)→slice(0, lastIndex)— equivalent specifically because the start is0, solengthand the end index coincide.cloneNoteName():substr(lastIndex)→slice(lastIndex)— single-arg, runs to end of string (equivalent).Generated names for both new notes (
Untitled Note N) and cloned notes are unchanged from current behavior.What type of PR is it?
Improvement
Todos
substr()calls withslice()substr()usage in the fileWhat is the Jira issue?
ZEPPELIN-6473
How should this be tested?
This repository's frontend has no unit-test infrastructure, so verification is via lint plus a production build:
Both pass.
Questions: