diff --git a/apps/content-analysis/config/paths.js b/apps/content-analysis/config/paths.js index fc7e9a54d40..8e91c745d6f 100644 --- a/apps/content-analysis/config/paths.js +++ b/apps/content-analysis/config/paths.js @@ -14,7 +14,7 @@ const envPublicUrl = process.env.PUBLIC_URL; function ensureSlash( inputPath, needsSlash ) { const hasSlash = inputPath.endsWith( "/" ); if ( hasSlash && ! needsSlash ) { - return inputPath.substr( 0, inputPath.length - 1 ); + return inputPath.substring( 0, inputPath.length - 1 ); } else if ( ! hasSlash && needsSlash ) { return `${inputPath}/`; } diff --git a/config/webpack/webpack.config.base.js b/config/webpack/webpack.config.base.js index 8ea1e419241..55fdee2e092 100644 --- a/config/webpack/webpack.config.base.js +++ b/config/webpack/webpack.config.base.js @@ -51,10 +51,10 @@ module.exports = function( { entry, output, combinedOutputFile, cssExtractFileNa return [ "yoast", yoastExternals[ request ] ]; } if ( request.startsWith( "lodash/" ) ) { - return [ "lodash", request.substr( 7 ) ]; + return [ "lodash", request.substring( 7 ) ]; } if ( request.startsWith( "lodash-es/" ) ) { - return [ "lodash", request.substr( 10 ) ]; + return [ "lodash", request.substring( 10 ) ]; } if ( request === "react-select" ) { return [ "yoast", "reactSelect" ]; @@ -63,7 +63,7 @@ module.exports = function( { entry, output, combinedOutputFile, cssExtractFileNa return [ "yoast", "reactSelectAsync" ]; } if ( request.startsWith( "@yoast/externals/" ) ) { - return [ "yoast", "externals", request.substr( 17 ) ]; + return [ "yoast", "externals", request.substring( 17 ) ]; } }, /** @@ -85,7 +85,7 @@ module.exports = function( { entry, output, combinedOutputFile, cssExtractFileNa return "yoast-seo-react-select"; } if ( request.startsWith( "@yoast/externals/" ) ) { - return "yoast-seo-externals-" + request.substr( 17 ); + return "yoast-seo-externals-" + request.substring( 17 ); } }, } ), diff --git a/packages/components/src/GenerateId.js b/packages/components/src/GenerateId.js index 816b0cdcdf2..eae466788b8 100644 --- a/packages/components/src/GenerateId.js +++ b/packages/components/src/GenerateId.js @@ -6,7 +6,7 @@ * @returns {string} A unique ID. */ const generateId = () => { - return Math.random().toString( 36 ).substr( 2, 6 ); + return Math.random().toString( 36 ).substring( 2, 6 ); }; /** diff --git a/packages/js/src/helpers/createInterpolateElement.js b/packages/js/src/helpers/createInterpolateElement.js index a999c3bc2c3..e6294e4065b 100644 --- a/packages/js/src/helpers/createInterpolateElement.js +++ b/packages/js/src/helpers/createInterpolateElement.js @@ -110,7 +110,7 @@ function addText() { if ( 0 === length ) { return; } - output.push( indoc.substr( offset, length ) ); + output.push( indoc.substring( offset, offset + length ) ); } /** @@ -127,10 +127,7 @@ function addText() { function addChild( frame ) { const { element, tokenStart, tokenLength, prevOffset, children } = frame; const parent = stack[ stack.length - 1 ]; - const text = indoc.substr( - parent.prevOffset, - tokenStart - parent.prevOffset - ); + const text = indoc.substring( parent.prevOffset, tokenStart ); if ( text ) { parent.children.push( text ); @@ -164,8 +161,8 @@ function closeOuterElement( endOffset ) { } = stack.pop(); const text = endOffset - ? indoc.substr( prevOffset, endOffset - prevOffset ) - : indoc.substr( prevOffset ); + ? indoc.substring( prevOffset, endOffset ) + : indoc.substring( prevOffset ); if ( text ) { children.push( text ); @@ -173,7 +170,7 @@ function closeOuterElement( endOffset ) { if ( null !== leadingTextStart ) { output.push( - indoc.substr( leadingTextStart, tokenStart - leadingTextStart ) + indoc.substring( leadingTextStart, tokenStart ) ); } @@ -228,7 +225,7 @@ function proceed( conversionMap ) { leadingTextStart: stackLeadingText, tokenStart, } = stack.pop(); - output.push( indoc.substr( stackLeadingText, tokenStart ) ); + output.push( indoc.substring( stackLeadingText, stackLeadingText + tokenStart ) ); } addText(); return false; @@ -237,9 +234,9 @@ function proceed( conversionMap ) { if ( 0 === stackDepth ) { if ( null !== leadingTextStart ) { output.push( - indoc.substr( + indoc.substring( leadingTextStart, - startOffset - leadingTextStart + startOffset ) ); } @@ -280,10 +277,7 @@ function proceed( conversionMap ) { // Otherwise we're nested and we have to close out the current // Block and add it as a innerBlock to the parent const stackTop = stack.pop(); - const text = indoc.substr( - stackTop.prevOffset, - startOffset - stackTop.prevOffset - ); + const text = indoc.substring( stackTop.prevOffset, startOffset ); stackTop.children.push( text ); stackTop.prevOffset = startOffset + tokenLength; const frame = createFrame( diff --git a/packages/js/src/helpers/replacementVariableHelpers.js b/packages/js/src/helpers/replacementVariableHelpers.js index c8e5b5fdd52..52a44bd3ac6 100644 --- a/packages/js/src/helpers/replacementVariableHelpers.js +++ b/packages/js/src/helpers/replacementVariableHelpers.js @@ -47,7 +47,7 @@ export function handlePrefixes( name ) { const prefixes = [ "ct_", "cf_", "pt_" ]; // If there are no prefixes, replace underscores by spaces and return. - if ( ! prefixes.includes( name.substr( 0, 3 ) ) ) { + if ( ! prefixes.includes( name.substring( 0, 3 ) ) ) { return name.replace( /_/g, " " ); } diff --git a/packages/js/src/initializers/post-scraper.js b/packages/js/src/initializers/post-scraper.js index 95a59d608e8..62ae0ed3d81 100644 --- a/packages/js/src/initializers/post-scraper.js +++ b/packages/js/src/initializers/post-scraper.js @@ -106,7 +106,7 @@ export default function initPostScraper( $, store, editorData ) { */ jQuery( document ).on( "ajaxComplete", function( ev, response, ajaxOptions ) { const ajaxEndPoint = "/admin-ajax.php"; - if ( ajaxEndPoint !== ajaxOptions.url.substr( 0 - ajaxEndPoint.length ) ) { + if ( ajaxEndPoint !== ajaxOptions.url.substring( ajaxOptions.url.length - ajaxEndPoint.length ) ) { return; } diff --git a/packages/js/src/workouts/components/WorkoutsPage.js b/packages/js/src/workouts/components/WorkoutsPage.js index 80e12aed1a2..6c9320bd4da 100644 --- a/packages/js/src/workouts/components/WorkoutsPage.js +++ b/packages/js/src/workouts/components/WorkoutsPage.js @@ -70,10 +70,10 @@ export default function WorkoutsPage( props ) { if ( loading === true ) { initWorkouts( workoutsSetting ); if ( window.location.hash && window.location.hash.length > 1 ) { - if ( window.location.hash.substr( 1 ) === "configuration" ) { + if ( window.location.hash.substring( 1 ) === "configuration" ) { window.location.href = window.wpseoWorkoutsData.firstTimeConfigurationUrl; } else { - openWorkout( window.location.hash.substr( 1 ) ); + openWorkout( window.location.hash.substring( 1 ) ); } } return; diff --git a/packages/yoastseo/spec/languageProcessing/languages/en/config/abbreviationsSpec.js b/packages/yoastseo/spec/languageProcessing/languages/en/config/abbreviationsSpec.js index e07cd0db6a3..97595e52623 100644 --- a/packages/yoastseo/spec/languageProcessing/languages/en/config/abbreviationsSpec.js +++ b/packages/yoastseo/spec/languageProcessing/languages/en/config/abbreviationsSpec.js @@ -3,7 +3,7 @@ import englishAbbreviations from "../../../../../src/languageProcessing/language describe( "tests if all abbreviations end with a fullstop", function() { englishAbbreviations.forEach( ( abbreviation ) =>{ it( abbreviation + " should end with a fullstop", function() { - const lastChar = abbreviation.substr( abbreviation.length - 1 ); + const lastChar = abbreviation.substring( abbreviation.length - 1 ); expect( lastChar ).toBe( "." ); } ); } ); diff --git a/packages/yoastseo/src/languageProcessing/helpers/passiveVoice/periphrastic/freeAuxiliaryParticipleOrder/getClausesSplitOnStopWords.js b/packages/yoastseo/src/languageProcessing/helpers/passiveVoice/periphrastic/freeAuxiliaryParticipleOrder/getClausesSplitOnStopWords.js index cc6ecd4a244..9834b30bcb1 100644 --- a/packages/yoastseo/src/languageProcessing/helpers/passiveVoice/periphrastic/freeAuxiliaryParticipleOrder/getClausesSplitOnStopWords.js +++ b/packages/yoastseo/src/languageProcessing/helpers/passiveVoice/periphrastic/freeAuxiliaryParticipleOrder/getClausesSplitOnStopWords.js @@ -33,7 +33,7 @@ function splitOnStopWords( sentence, stopwords ) { } const startIndex = sentence.indexOf( stopword ); const endIndex = sentence.length; - sentence = stripSpaces( sentence.substr( startIndex, endIndex ) ); + sentence = stripSpaces( sentence.substring( startIndex, endIndex ) ); } ); // Push the remainder of the sentence in the clauses array. diff --git a/packages/yoastseo/src/languageProcessing/helpers/passiveVoice/periphrastic/getClauses.js b/packages/yoastseo/src/languageProcessing/helpers/passiveVoice/periphrastic/getClauses.js index 2731ed88762..c2817bde2ca 100644 --- a/packages/yoastseo/src/languageProcessing/helpers/passiveVoice/periphrastic/getClauses.js +++ b/packages/yoastseo/src/languageProcessing/helpers/passiveVoice/periphrastic/getClauses.js @@ -205,7 +205,7 @@ const getClauses = function( sentence, options ) { } // Cut the sentence from the current index to the endIndex (start of next breaker, of end of sentence). - const clause = stripSpaces( sentence.substr( indices[ i ].index, endIndex - indices[ i ].index ) ); + const clause = stripSpaces( sentence.substring( indices[ i ].index, endIndex ) ); const auxiliaryMatches = getAuxiliaryMatches( clause, options.regexes ); // If a clause doesn't have an auxiliary, we don't need it, so it can be filtered out. diff --git a/packages/yoastseo/src/languageProcessing/languages/id/helpers/internal/stem.js b/packages/yoastseo/src/languageProcessing/languages/id/helpers/internal/stem.js index 69382623c76..d6c6f8fc09f 100644 --- a/packages/yoastseo/src/languageProcessing/languages/id/helpers/internal/stem.js +++ b/packages/yoastseo/src/languageProcessing/languages/id/helpers/internal/stem.js @@ -357,10 +357,10 @@ const stemPlural = function( word, morphologyData ) { * we compare the two parts of the word after stripping the variable first or first and second letter. * */ - const firstPartBeginningTrimmed = firstPart.substr( 1 ); + const firstPartBeginningTrimmed = firstPart.substring( 1 ); const secondPartBeginningTrimmed = ( secondPart.startsWith( "ng" ) || secondPart.startsWith( "ny" ) ) - ? secondPart.substr( 2 ) - : secondPart.substr( 1 ); + ? secondPart.substring( 2 ) + : secondPart.substring( 1 ); if ( firstPartBeginningTrimmed === secondPartBeginningTrimmed ) { const nonPlurals = morphologyData.stemming.nonPluralReduplications; diff --git a/packages/yoastseo/src/languageProcessing/languages/ja/customResearches/findKeyphraseInSEOTitle.js b/packages/yoastseo/src/languageProcessing/languages/ja/customResearches/findKeyphraseInSEOTitle.js index 8668b97db7a..88059208ac6 100644 --- a/packages/yoastseo/src/languageProcessing/languages/ja/customResearches/findKeyphraseInSEOTitle.js +++ b/packages/yoastseo/src/languageProcessing/languages/ja/customResearches/findKeyphraseInSEOTitle.js @@ -22,7 +22,7 @@ function adjustPosition( title, position ) { } // Retrieve the SEO title words before the keyphrase. - let titleBeforeKeyword = title.substr( 0, position ); + let titleBeforeKeyword = title.substring( 0, position ); titleBeforeKeyword = getWords( titleBeforeKeyword ); // Retrieve the non-function words. titleBeforeKeyword = titleBeforeKeyword.filter( word => ! functionWords.includes( word ) ); diff --git a/packages/yoastseo/src/languageProcessing/languages/ru/helpers/internal/stem.js b/packages/yoastseo/src/languageProcessing/languages/ru/helpers/internal/stem.js index 629a03900e1..37e864b5a93 100644 --- a/packages/yoastseo/src/languageProcessing/languages/ru/helpers/internal/stem.js +++ b/packages/yoastseo/src/languageProcessing/languages/ru/helpers/internal/stem.js @@ -85,8 +85,8 @@ const findRvRegion = function( word, morphologyData ) { * @returns {string|null} The word if the stemming rule could be applied or null otherwise. */ const removeEndings = function( word, regex, region ) { - const prefix = word.substr( 0, region ); - const ending = word.substr( prefix.length ); + const prefix = word.substring( 0, region ); + const ending = word.substring( prefix.length ); let currentRegex; @@ -120,8 +120,8 @@ const removeEndings = function( word, regex, region ) { * @returns {string} The stemmed word if the word has perfective prefix an verb suffix, otherwise the original word. */ const removePerfectivePrefix = function( word, morphologyData, rv ) { - const prefix = word.substr( 0, rv ); - const ending = word.substr( prefix.length ); + const prefix = word.substring( 0, rv ); + const ending = word.substring( prefix.length ); const perfectiveEndingsRegex = new RegExp( morphologyData.externalStemmer.regexPerfectiveEndings, "i" ); @@ -263,7 +263,7 @@ export default function stem( word, morphologyData ) { // Step 4: There can be one of three options: // 1. If the word ends in нн, remove the last letter. if ( word.endsWith( morphologyData.externalStemmer.doubleN ) ) { - word = word.substr( 0, word.length - 1 ); + word = word.substring( 0, word.length - 1 ); } // 2. If the word ends in a SUPERLATIVE ending, remove it and then again the last letter if the word ends in "нн". diff --git a/packages/yoastseo/src/languageProcessing/researches/findKeyphraseInSEOTitle.js b/packages/yoastseo/src/languageProcessing/researches/findKeyphraseInSEOTitle.js index 6245a3b0b19..1f77a1d08f9 100644 --- a/packages/yoastseo/src/languageProcessing/researches/findKeyphraseInSEOTitle.js +++ b/packages/yoastseo/src/languageProcessing/researches/findKeyphraseInSEOTitle.js @@ -60,7 +60,7 @@ const adjustPosition = function( title, position ) { } // Strip all function words from the beginning of the SEO title. - const titleBeforeKeyword = title.substr( 0, position ); + const titleBeforeKeyword = title.substring( 0, position ); if ( stripFunctionWordsFromStart( titleBeforeKeyword ) ) { /* * Return position 0 if there are no words left in the SEO title before the keyword after filtering diff --git a/packages/yoastseo/src/markers/addMarkSingleWord.js b/packages/yoastseo/src/markers/addMarkSingleWord.js index 98c65762906..94ef26ae916 100644 --- a/packages/yoastseo/src/markers/addMarkSingleWord.js +++ b/packages/yoastseo/src/markers/addMarkSingleWord.js @@ -17,7 +17,7 @@ export default function( text ) { // Get the actual word boundaries from the start of the text. if ( strippedTextStart !== text ) { const wordBoundaryStartIndex = text.search( escapeRegExp( strippedTextStart ) ); - wordBoundaryStart = text.substr( 0, wordBoundaryStartIndex ); + wordBoundaryStart = text.substring( 0, wordBoundaryStartIndex ); } // Strip word boundaries at the end of the text. @@ -25,7 +25,7 @@ export default function( text ) { // Get the actual word boundaries from the end of the text. if ( strippedTextEnd !== strippedTextStart ) { const wordBoundaryEndIndex = strippedTextStart.search( escapeRegExp( strippedTextEnd ) ) + strippedTextEnd.length; - wordBoundaryEnd = strippedTextStart.substr( wordBoundaryEndIndex ); + wordBoundaryEnd = strippedTextStart.substring( wordBoundaryEndIndex ); } return wordBoundaryStart + "" + strippedTextEnd + "" + wordBoundaryEnd;