• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Yoast / wordpress-seo / bd4fb5b465aecaf6795c5e18878a3b74fd4847b4

08 May 2025 07:46AM UTC coverage: 52.795% (+0.3%) from 52.524%
bd4fb5b465aecaf6795c5e18878a3b74fd4847b4

push

github

FAMarfuaty
Merge branch 'trunk' of github.com:Yoast/wordpress-seo into feature/ai-optimize-classic

8129 of 14281 branches covered (56.92%)

Branch coverage included in aggregate %.

27 of 71 new or added lines in 24 files covered. (38.03%)

51 existing lines in 1 file now uncovered.

29567 of 57120 relevant lines covered (51.76%)

41799.5 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

10.0
/packages/js/src/helpers/stringHelpers.js
1
import { safeCreateInterpolateElement } from "./i18n";
2

3
/**
4
 * Capitalize the first letter of a string.
5
 *
6
 * @param   {string} string The string to capitalize.
7
 *
8
 * @returns {string}        The string with the first letter capitalized.
9
 */
10
export function firstToUpperCase( string ) {
11
        return string.charAt( 0 ).toUpperCase() + string.slice( 1 );
72✔
12
}
13

14
/**
15
 * Strips HTML from a string.
16
 *
17
 * @param {string} string  The string to strip HTML from.
18
 *
19
 * @returns {string} The string with HTML stripped.
20
 */
21
export function stripHTML( string ) {
22
        const tmp = document.createElement( "DIV" );
×
23
        tmp.innerHTML = string;
×
24
        return tmp.textContent || tmp.innerText || "";
×
25
}
26

27
/**
28
 * Adds a link to a string containing anchor tags (in string form).
29
 *
30
 * @example "This is an example text in which <a>this part should be a link</a> and this part shouldn't."
31
 *
32
 * @param {string} text   The text to add links to. Make sure it contains <a> and </a> tags surrounding the link part.
33
 * @param {string} linkTo The target URL for the link (href).
34
 * @param {string} id     The id to attach to the link.
35
 *
36
 * @returns {WPElement} A Fragment with the text and a link.
37
 */
38
export function addLinkToString( text, linkTo, id = "" ) {
×
NEW
39
        return safeCreateInterpolateElement(
×
40
                text,
41
                {
42
                        // eslint-disable-next-line jsx-a11y/anchor-has-content
43
                        a: <a id={ id } href={ linkTo } target="_blank" rel="noopener noreferrer" />,
44
                }
45
        );
46
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc