-
Notifications
You must be signed in to change notification settings - Fork 155
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
refactor: replace deprecated String.prototype.substr() #6718
refactor: replace deprecated String.prototype.substr() #6718
Conversation
Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes. |
@CommanderRoot thanks for the effort, could you rebase and squash your commits so we can merge? :) |
.substr() is deprecated so we replace it with functions which work similarily but aren't deprecated Signed-off-by: Tobias Speicher <[email protected]>
Kudos, SonarCloud Quality Gate passed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank's a lot for your contribution 🤩
@@ -170,7 +170,8 @@ export default { | |||
isSameResource(this.resourcesToDelete[0], this.currentFolder) | |||
) { | |||
const resourcePath = this.resourcesToDelete[0].path | |||
parentFolderPath = resourcePath.substr(0, resourcePath.lastIndexOf('/')) | |||
const lastSlash = resourcePath.lastIndexOf('/') | |||
parentFolderPath = resourcePath.slice(0, lastSlash !== -1 ? lastSlash : 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I would've handled the lastSlash being -1
outside of slice
, but it works as expected, so I'm fine with it. 😉
Description
String.prototype.substr() is deprecated so we replace it with String.prototype.slice() which works similarily but isn't deprecated.
.substr() probably isn't going away anytime soon but the change is trivial so it doesn't hurt to do it.
Related Issue
Motivation and Context
String.prototype.substr() is deprecated .
How Has This Been Tested?
I tested the return of each statement to make sure it's still the same as before
Screenshots (if appropriate):
Types of changes
Checklist:
Open tasks: