Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
b12d6546
Commit
b12d6546
authored
May 03, 2018
by
Olivier Gonzalez
Committed by
Phil Hughes
May 03, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add pass through to stripHtml for undefined and null inputs
parent
6aad7b49
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletion
+13
-1
app/assets/javascripts/lib/utils/text_utility.js
app/assets/javascripts/lib/utils/text_utility.js
+5
-1
spec/javascripts/lib/utils/text_utility_spec.js
spec/javascripts/lib/utils/text_utility_spec.js
+8
-0
No files found.
app/assets/javascripts/lib/utils/text_utility.js
View file @
b12d6546
...
@@ -74,7 +74,11 @@ export function capitalizeFirstCharacter(text) {
...
@@ -74,7 +74,11 @@ export function capitalizeFirstCharacter(text) {
* @param {*} replace
* @param {*} replace
* @returns {String}
* @returns {String}
*/
*/
export
const
stripHtml
=
(
string
,
replace
=
''
)
=>
string
.
replace
(
/<
[^
>
]
*>/g
,
replace
);
export
const
stripHtml
=
(
string
,
replace
=
''
)
=>
{
if
(
!
string
)
return
string
;
return
string
.
replace
(
/<
[^
>
]
*>/g
,
replace
);
};
/**
/**
* Converts snake_case string to camelCase
* Converts snake_case string to camelCase
...
...
spec/javascripts/lib/utils/text_utility_spec.js
View file @
b12d6546
...
@@ -75,6 +75,14 @@ describe('text_utility', () => {
...
@@ -75,6 +75,14 @@ describe('text_utility', () => {
'
This is a text with html .
'
,
'
This is a text with html .
'
,
);
);
});
});
it
(
'
passes through with null string input
'
,
()
=>
{
expect
(
textUtils
.
stripHtml
(
null
,
'
'
)).
toEqual
(
null
);
});
it
(
'
passes through with undefined string input
'
,
()
=>
{
expect
(
textUtils
.
stripHtml
(
undefined
,
'
'
)).
toEqual
(
undefined
);
});
});
});
describe
(
'
convertToCamelCase
'
,
()
=>
{
describe
(
'
convertToCamelCase
'
,
()
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment