chore: replace deprecated String.prototype.substr() (#11928)
String.prototype.substr() is deprecated (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr) so we replace it with slice() which works similarily but isn't deprecated Signed-off-by: Tobias Speicher <rootcommander@gmail.com>
This commit is contained in:
parent
4cd69fe4d8
commit
a778a98016
|
|
@ -387,7 +387,7 @@ Cypress.Commands.add(
|
||||||
element: true,
|
element: true,
|
||||||
},
|
},
|
||||||
($element, text) => {
|
($element, text) => {
|
||||||
const subString = text.substr(0, text.length - 1);
|
const subString = text.slice(0, -1);
|
||||||
const lastChar = text.slice(-1);
|
const lastChar = text.slice(-1);
|
||||||
|
|
||||||
cy.get(commonlocators.entityExplorersearch)
|
cy.get(commonlocators.entityExplorersearch)
|
||||||
|
|
|
||||||
|
|
@ -166,7 +166,7 @@ exports.handler = async (event, context, callback) => {
|
||||||
if (page.markdown) {
|
if (page.markdown) {
|
||||||
const size = JSON.stringify(page).length;
|
const size = JSON.stringify(page).length;
|
||||||
if (size > 10000) {
|
if (size > 10000) {
|
||||||
page.markdown = page.markdown.substr(0, page.markdown.length - (JSON.stringify(page).length - 9900));
|
page.markdown = page.markdown.slice(0, -(size - 9900));
|
||||||
}
|
}
|
||||||
if (orderMap[page.path]) {
|
if (orderMap[page.path]) {
|
||||||
page.isDefault = true;
|
page.isDefault = true;
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ export const getIndexOfRegex = (
|
||||||
regex: RegExp,
|
regex: RegExp,
|
||||||
start = 0,
|
start = 0,
|
||||||
): number => {
|
): number => {
|
||||||
const pos = str.substr(start).search(regex);
|
const pos = str.slice(start).search(regex);
|
||||||
return pos > -1 ? pos + start : pos;
|
return pos > -1 ? pos + start : pos;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -44,7 +44,7 @@ export const getKeyPositionInString = (
|
||||||
let positions: Position[] = [];
|
let positions: Position[] = [];
|
||||||
if (str.includes("\n")) {
|
if (str.includes("\n")) {
|
||||||
for (const index of indices) {
|
for (const index of indices) {
|
||||||
const substr = str.substr(0, index);
|
const substr = str.slice(0, index);
|
||||||
const substrLines = substr.split("\n");
|
const substrLines = substr.split("\n");
|
||||||
const ch = last(substrLines)?.length || 0;
|
const ch = last(substrLines)?.length || 0;
|
||||||
const line = substrLines.length - 1;
|
const line = substrLines.length - 1;
|
||||||
|
|
@ -103,7 +103,7 @@ export const getLintAnnotations = (
|
||||||
bindingLocation.line !== currentLine ? ch : bindingLocation.ch + ch;
|
bindingLocation.line !== currentLine ? ch : bindingLocation.ch + ch;
|
||||||
// Jshint counts \t as two characters and codemirror counts it as 1.
|
// Jshint counts \t as two characters and codemirror counts it as 1.
|
||||||
// So we need to subtract number of tabs to get accurate position
|
// So we need to subtract number of tabs to get accurate position
|
||||||
const tabs = lineContent.substr(0, currentCh).match(/\t/g)?.length || 0;
|
const tabs = lineContent.slice(0, currentCh).match(/\t/g)?.length || 0;
|
||||||
|
|
||||||
const from = {
|
const from = {
|
||||||
line: currentLine,
|
line: currentLine,
|
||||||
|
|
|
||||||
|
|
@ -255,7 +255,7 @@ export const actionPathFromName = (
|
||||||
const ActionConfigStarts = "actionConfiguration.";
|
const ActionConfigStarts = "actionConfiguration.";
|
||||||
let path = name;
|
let path = name;
|
||||||
if (path.startsWith(ActionConfigStarts)) {
|
if (path.startsWith(ActionConfigStarts)) {
|
||||||
path = "config." + path.substr(ActionConfigStarts.length);
|
path = "config." + path.slice(ActionConfigStarts.length);
|
||||||
}
|
}
|
||||||
return `${actionName}.${path}`;
|
return `${actionName}.${path}`;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ function WidgetsEditor() {
|
||||||
window.location.hash.length > 0 &&
|
window.location.hash.length > 0 &&
|
||||||
!guidedTourEnabled
|
!guidedTourEnabled
|
||||||
) {
|
) {
|
||||||
const widgetIdFromURLHash = window.location.hash.substr(1);
|
const widgetIdFromURLHash = window.location.hash.slice(1);
|
||||||
flashElementsById(widgetIdFromURLHash);
|
flashElementsById(widgetIdFromURLHash);
|
||||||
if (document.getElementById(widgetIdFromURLHash))
|
if (document.getElementById(widgetIdFromURLHash))
|
||||||
selectWidget(widgetIdFromURLHash);
|
selectWidget(widgetIdFromURLHash);
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,7 @@ export default function Settings() {
|
||||||
let newUrl = "";
|
let newUrl = "";
|
||||||
|
|
||||||
if (hasSlash) {
|
if (hasSlash) {
|
||||||
newUrl = `${location.pathname.substr(0, settingsEndIndex)}/${
|
newUrl = `${location.pathname.slice(0, settingsEndIndex)}/${
|
||||||
tabArr[index].key
|
tabArr[index].key
|
||||||
}`;
|
}`;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ export function parseUrlForQueryParams(url: string) {
|
||||||
const matchGroup = url.match(queryParamsRegEx) || [];
|
const matchGroup = url.match(queryParamsRegEx) || [];
|
||||||
const parsedUrlWithQueryParams = matchGroup[2] || "";
|
const parsedUrlWithQueryParams = matchGroup[2] || "";
|
||||||
if (parsedUrlWithQueryParams.indexOf("?") > -1) {
|
if (parsedUrlWithQueryParams.indexOf("?") > -1) {
|
||||||
const paramsString = parsedUrlWithQueryParams.substr(
|
const paramsString = parsedUrlWithQueryParams.slice(
|
||||||
parsedUrlWithQueryParams.indexOf("?") + 1,
|
parsedUrlWithQueryParams.indexOf("?") + 1,
|
||||||
);
|
);
|
||||||
params = paramsString.split("&").map((p) => {
|
params = paramsString.split("&").map((p) => {
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ export const limitDecimalValue = (decimals = 0, value = "") => {
|
||||||
return (
|
return (
|
||||||
decimalValueArray[0] +
|
decimalValueArray[0] +
|
||||||
decimalSeperator +
|
decimalSeperator +
|
||||||
decimalValueArray[1].substr(0, decimals)
|
decimalValueArray[1].slice(0, decimals)
|
||||||
);
|
);
|
||||||
default:
|
default:
|
||||||
return value;
|
return value;
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ const ErrorWrapper = styled.div`
|
||||||
|
|
||||||
const checkUrlExtension = (docUrl: string) => {
|
const checkUrlExtension = (docUrl: string) => {
|
||||||
// Remove everything to the last slash in URL
|
// Remove everything to the last slash in URL
|
||||||
let url = docUrl.substr(1 + docUrl.lastIndexOf("/"));
|
let url = docUrl.slice(1 + docUrl.lastIndexOf("/"));
|
||||||
// Break URL at ? and take first part (file name, extension)
|
// Break URL at ? and take first part (file name, extension)
|
||||||
url = url.split("?")[0];
|
url = url.split("?")[0];
|
||||||
// Sometimes URL doesn't have ? but #, so we should aslo do the same for #
|
// Sometimes URL doesn't have ? but #, so we should aslo do the same for #
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ export const limitDecimalValue = (
|
||||||
value =
|
value =
|
||||||
decimalValueArray[0] +
|
decimalValueArray[0] +
|
||||||
decimalSeparator +
|
decimalSeparator +
|
||||||
decimalValueArray[1].substr(0, decimalsInCurrency);
|
decimalValueArray[1].slice(0, decimalsInCurrency);
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ export const getPositionInEvaluationScript = (
|
||||||
const script = EvaluationScripts[type];
|
const script = EvaluationScripts[type];
|
||||||
|
|
||||||
const index = script.indexOf(ScriptTemplate);
|
const index = script.indexOf(ScriptTemplate);
|
||||||
const substr = script.substr(0, index);
|
const substr = script.slice(0, index !== -1 ? index : 0);
|
||||||
const lines = substr.split("\n");
|
const lines = substr.split("\n");
|
||||||
const lastLine = last(lines) || "";
|
const lastLine = last(lines) || "";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -332,7 +332,7 @@ async function watchMongoDB(io) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the type from _class attribute
|
// set the type from _class attribute
|
||||||
notification.type = notification._class.substr(notification._class.lastIndexOf(".") + 1);
|
notification.type = notification._class.slice(notification._class.lastIndexOf(".") + 1);
|
||||||
delete notification._class;
|
delete notification._class;
|
||||||
|
|
||||||
const eventName = event.operationType + ":" + event.ns.coll;
|
const eventName = event.operationType + ":" + event.ns.coll;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user