diff --git a/app/client/cypress/support/commands.js b/app/client/cypress/support/commands.js index 7795b34d77..0c34c5e311 100644 --- a/app/client/cypress/support/commands.js +++ b/app/client/cypress/support/commands.js @@ -387,7 +387,7 @@ Cypress.Commands.add( element: true, }, ($element, text) => { - const subString = text.substr(0, text.length - 1); + const subString = text.slice(0, -1); const lastChar = text.slice(-1); cy.get(commonlocators.entityExplorersearch) diff --git a/app/client/gitbook-algolia-lambda.js b/app/client/gitbook-algolia-lambda.js index 722620b62d..e55efb7e9a 100644 --- a/app/client/gitbook-algolia-lambda.js +++ b/app/client/gitbook-algolia-lambda.js @@ -165,8 +165,8 @@ exports.handler = async (event, context, callback) => { .forEach(page => { if (page.markdown) { const size = JSON.stringify(page).length; - if (size > 10000) { - page.markdown = page.markdown.substr(0, page.markdown.length - (JSON.stringify(page).length - 9900)); + if (size > 10000) { + page.markdown = page.markdown.slice(0, -(size - 9900)); } if (orderMap[page.path]) { page.isDefault = true; diff --git a/app/client/src/components/editorComponents/CodeEditor/lintHelpers.ts b/app/client/src/components/editorComponents/CodeEditor/lintHelpers.ts index 1fbce02db7..c2a106ad9c 100644 --- a/app/client/src/components/editorComponents/CodeEditor/lintHelpers.ts +++ b/app/client/src/components/editorComponents/CodeEditor/lintHelpers.ts @@ -12,7 +12,7 @@ export const getIndexOfRegex = ( regex: RegExp, start = 0, ): number => { - const pos = str.substr(start).search(regex); + const pos = str.slice(start).search(regex); return pos > -1 ? pos + start : pos; }; @@ -44,7 +44,7 @@ export const getKeyPositionInString = ( let positions: Position[] = []; if (str.includes("\n")) { for (const index of indices) { - const substr = str.substr(0, index); + const substr = str.slice(0, index); const substrLines = substr.split("\n"); const ch = last(substrLines)?.length || 0; const line = substrLines.length - 1; @@ -103,7 +103,7 @@ export const getLintAnnotations = ( bindingLocation.line !== currentLine ? ch : bindingLocation.ch + ch; // Jshint counts \t as two characters and codemirror counts it as 1. // 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 = { line: currentLine, diff --git a/app/client/src/components/formControls/utils.ts b/app/client/src/components/formControls/utils.ts index f75a3e7e03..c06ebcae9a 100644 --- a/app/client/src/components/formControls/utils.ts +++ b/app/client/src/components/formControls/utils.ts @@ -255,7 +255,7 @@ export const actionPathFromName = ( const ActionConfigStarts = "actionConfiguration."; let path = name; if (path.startsWith(ActionConfigStarts)) { - path = "config." + path.substr(ActionConfigStarts.length); + path = "config." + path.slice(ActionConfigStarts.length); } return `${actionName}.${path}`; }; diff --git a/app/client/src/pages/Editor/WidgetsEditor/index.tsx b/app/client/src/pages/Editor/WidgetsEditor/index.tsx index 068a8fe773..6a7bfc1172 100644 --- a/app/client/src/pages/Editor/WidgetsEditor/index.tsx +++ b/app/client/src/pages/Editor/WidgetsEditor/index.tsx @@ -74,7 +74,7 @@ function WidgetsEditor() { window.location.hash.length > 0 && !guidedTourEnabled ) { - const widgetIdFromURLHash = window.location.hash.substr(1); + const widgetIdFromURLHash = window.location.hash.slice(1); flashElementsById(widgetIdFromURLHash); if (document.getElementById(widgetIdFromURLHash)) selectWidget(widgetIdFromURLHash); diff --git a/app/client/src/pages/organization/settings.tsx b/app/client/src/pages/organization/settings.tsx index ca9eea8bb4..47fd45edb6 100644 --- a/app/client/src/pages/organization/settings.tsx +++ b/app/client/src/pages/organization/settings.tsx @@ -106,7 +106,7 @@ export default function Settings() { let newUrl = ""; if (hasSlash) { - newUrl = `${location.pathname.substr(0, settingsEndIndex)}/${ + newUrl = `${location.pathname.slice(0, settingsEndIndex)}/${ tabArr[index].key }`; } else { diff --git a/app/client/src/utils/ApiPaneUtils.tsx b/app/client/src/utils/ApiPaneUtils.tsx index 99dcf492c8..059216abf0 100644 --- a/app/client/src/utils/ApiPaneUtils.tsx +++ b/app/client/src/utils/ApiPaneUtils.tsx @@ -26,7 +26,7 @@ export function parseUrlForQueryParams(url: string) { const matchGroup = url.match(queryParamsRegEx) || []; const parsedUrlWithQueryParams = matchGroup[2] || ""; if (parsedUrlWithQueryParams.indexOf("?") > -1) { - const paramsString = parsedUrlWithQueryParams.substr( + const paramsString = parsedUrlWithQueryParams.slice( parsedUrlWithQueryParams.indexOf("?") + 1, ); params = paramsString.split("&").map((p) => { diff --git a/app/client/src/widgets/CurrencyInputWidget/component/utilities.ts b/app/client/src/widgets/CurrencyInputWidget/component/utilities.ts index e90ba1e779..6b5690daec 100644 --- a/app/client/src/widgets/CurrencyInputWidget/component/utilities.ts +++ b/app/client/src/widgets/CurrencyInputWidget/component/utilities.ts @@ -11,10 +11,10 @@ export const countryToFlag = (isoCode: string) => { }; /* - Returns formatted value with maximum number of decimals based on decimalsInCurrency value + Returns formatted value with maximum number of decimals based on decimalsInCurrency value and add commas based on user's locale for eg: - a) (2, 1235.456) will return 1,235.45 + a) (2, 1235.456) will return 1,235.45 b) (1, 1234.456) will return 1,234.4 */ export const formatCurrencyNumber = (decimalsInCurrency = 0, value: string) => { @@ -34,7 +34,7 @@ export const formatCurrencyNumber = (decimalsInCurrency = 0, value: string) => { /* Returns value in string format with maximum number of decimals based on decimalsInCurrency value for eg: - a) (2, 1235.456) will return 1235.45 + a) (2, 1235.456) will return 1235.45 b) (1, 1234.456) will return 1234.4 */ export const limitDecimalValue = (decimals = 0, value = "") => { @@ -49,7 +49,7 @@ export const limitDecimalValue = (decimals = 0, value = "") => { return ( decimalValueArray[0] + decimalSeperator + - decimalValueArray[1].substr(0, decimals) + decimalValueArray[1].slice(0, decimals) ); default: return value; diff --git a/app/client/src/widgets/DocumentViewerWidget/component/index.tsx b/app/client/src/widgets/DocumentViewerWidget/component/index.tsx index a923f5a84f..bf6a42ca32 100644 --- a/app/client/src/widgets/DocumentViewerWidget/component/index.tsx +++ b/app/client/src/widgets/DocumentViewerWidget/component/index.tsx @@ -23,7 +23,7 @@ const ErrorWrapper = styled.div` const checkUrlExtension = (docUrl: string) => { // 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) url = url.split("?")[0]; // Sometimes URL doesn't have ? but #, so we should aslo do the same for # diff --git a/app/client/src/widgets/InputWidget/component/utilities.ts b/app/client/src/widgets/InputWidget/component/utilities.ts index b9cfbaad77..f5a5e48efc 100644 --- a/app/client/src/widgets/InputWidget/component/utilities.ts +++ b/app/client/src/widgets/InputWidget/component/utilities.ts @@ -9,10 +9,10 @@ export const countryToFlag = (isoCode: string) => { }; /* - Returns formatted value with maximum number of decimals based on decimalsInCurrency value + Returns formatted value with maximum number of decimals based on decimalsInCurrency value and add commas based on user's local browser for eg: - a) (2, 1235.456) will return 1,234.56 + a) (2, 1235.456) will return 1,234.56 b) (1, 1234.456) will return 1,234.5 */ export const formatCurrencyNumber = ( @@ -48,7 +48,7 @@ export const formatCurrencyNumber = ( /* Returns number in string format with maximum number of decimals based on decimalsInCurrency value for eg: - a) (2, 1235.456) will return 1234.56 + a) (2, 1235.456) will return 1234.56 b) (1, 1234.456) will return 1234.5 */ export const limitDecimalValue = ( @@ -68,7 +68,7 @@ export const limitDecimalValue = ( value = decimalValueArray[0] + decimalSeparator + - decimalValueArray[1].substr(0, decimalsInCurrency); + decimalValueArray[1].slice(0, decimalsInCurrency); } return value; } else { @@ -78,7 +78,7 @@ export const limitDecimalValue = ( /* Return the type of decimal separator for decimal digit numbers - eg: + eg: getDecimalSeparator("en-US") will return "." getDecimalSeparator("fr-FR") will return "," */ @@ -94,7 +94,7 @@ export const getDecimalSeparator = (locale: string) => { /* Return the type of decimal separator for decimal digit numbers - eg: + eg: getGroupSeparator("en-US") will return "," getGroupSeparator("fr-FR") will return " " */ diff --git a/app/client/src/workers/lint.ts b/app/client/src/workers/lint.ts index 24fba6c520..d5a6a79453 100644 --- a/app/client/src/workers/lint.ts +++ b/app/client/src/workers/lint.ts @@ -20,7 +20,7 @@ export const getPositionInEvaluationScript = ( const script = EvaluationScripts[type]; 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 lastLine = last(lines) || ""; diff --git a/app/rts/src/server.ts b/app/rts/src/server.ts index 86bbaf2858..2f8fdf48f7 100644 --- a/app/rts/src/server.ts +++ b/app/rts/src/server.ts @@ -332,7 +332,7 @@ async function watchMongoDB(io) { } // 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; const eventName = event.operationType + ":" + event.ns.coll;