Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5641097

Browse files
author
Jaroslaw Zolnowski
committed
refactor(hooks): suppress the codeql warning regarding replacing only the first occurrence of '>'
1 parent 3216297 commit 5641097

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

‎hooks/after_prepare/010_add_platform_class.js‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,15 @@ function addPlatformBodyTag(indexPath, platform) {
3737
newBodyTag = bodyTag.replace(classAttr, newClassAttr);
3838

3939
} else {
40+
41+
/*
42+
The bodyTag contains only the first found of `>`, due to the return of the first element of the array from method
43+
(findBodyTag)[https://github.com/xlts-dev/angularjs-ionic-v1/blob/c553c973d85142e66f119aed2fe3db83775f5f2b/hooks
44+
/after_prepare/010_add_platform_class.js#L57]. Therefore, we should replace only one tag
45+
*/
46+
var closingBracketIdx = bodyTag.indexOf('>');
4047
// add class attribute to the body tag
41-
newBodyTag = bodyTag.replace('>',' + platformClass + ' ' + cordovaClass + '">');
48+
newBodyTag = bodyTag.slice(0,closingBracketIdx)+' class="' + platformClass + ' ' + cordovaClass + bodyTag.slice(closingBracketIdx);
4249
}
4350

4451
html = html.replace(bodyTag, newBodyTag);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /