Skip to content

Commit

Permalink
Merge f221dd1 into 7fc2d47
Browse files Browse the repository at this point in the history
  • Loading branch information
mykola committed Mar 6, 2024
2 parents 7fc2d47 + f221dd1 commit 7e98a97
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 40 deletions.
2 changes: 1 addition & 1 deletion apps/content-analysis/config/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}/`;
}
Expand Down
8 changes: 4 additions & 4 deletions config/webpack/webpack.config.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -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" ];
Expand All @@ -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 ) ];
}
},
/**
Expand All @@ -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 );
}
},
} ),
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/GenerateId.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
};

/**
Expand Down
24 changes: 9 additions & 15 deletions packages/js/src/helpers/createInterpolateElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function addText() {
if ( 0 === length ) {
return;
}
output.push( indoc.substr( offset, length ) );
output.push( indoc.substring( offset, offset + length ) );
}

/**
Expand All @@ -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 );
Expand Down Expand Up @@ -164,16 +161,16 @@ 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 );
}

if ( null !== leadingTextStart ) {
output.push(
indoc.substr( leadingTextStart, tokenStart - leadingTextStart )
indoc.substring( leadingTextStart, tokenStart )
);
}

Expand Down Expand Up @@ -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;
Expand All @@ -237,9 +234,9 @@ function proceed( conversionMap ) {
if ( 0 === stackDepth ) {
if ( null !== leadingTextStart ) {
output.push(
indoc.substr(
indoc.substring(
leadingTextStart,
startOffset - leadingTextStart
startOffset
)
);
}
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion packages/js/src/helpers/replacementVariableHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, " " );
}

Expand Down
2 changes: 1 addition & 1 deletion packages/js/src/initializers/post-scraper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/js/src/workouts/components/WorkoutsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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( "." );
} );
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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" );

Expand Down Expand Up @@ -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 "нн".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions packages/yoastseo/src/markers/addMarkSingleWord.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ 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.
const strippedTextEnd = stripWordBoundariesEnd( strippedTextStart );
// 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 + "<yoastmark class='yoast-text-mark'>" + strippedTextEnd + "</yoastmark>" + wordBoundaryEnd;
Expand Down

0 comments on commit 7e98a97

Please sign in to comment.