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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
8ea50cd0
Commit
8ea50cd0
authored
Feb 07, 2018
by
Kushal Pandya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add `convertToCamelCase` helper method
parent
639bfb70
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
0 deletions
+13
-0
app/assets/javascripts/lib/utils/text_utility.js
app/assets/javascripts/lib/utils/text_utility.js
+7
-0
spec/javascripts/lib/utils/text_utility_spec.js
spec/javascripts/lib/utils/text_utility_spec.js
+6
-0
No files found.
app/assets/javascripts/lib/utils/text_utility.js
View file @
8ea50cd0
...
...
@@ -73,3 +73,10 @@ export function capitalizeFirstCharacter(text) {
* @returns {String}
*/
export
const
stripHtml
=
(
string
,
replace
=
''
)
=>
string
.
replace
(
/<
[^
>
]
*>/g
,
replace
);
/**
* Converts snake_case string to camelCase
*
* @param {*} string
*/
export
const
convertToCamelCase
=
string
=>
string
.
replace
(
/
(
_
\w)
/g
,
s
=>
s
[
1
].
toUpperCase
());
spec/javascripts/lib/utils/text_utility_spec.js
View file @
8ea50cd0
...
...
@@ -70,4 +70,10 @@ describe('text_utility', () => {
expect
(
textUtils
.
stripHtml
(
'
This is a text with <p>html</p>.
'
,
'
'
)).
toEqual
(
'
This is a text with html .
'
);
});
});
describe
(
'
convertToCamelCase
'
,
()
=>
{
it
(
'
converts snake_case string to camelCase string
'
,
()
=>
{
expect
(
textUtils
.
convertToCamelCase
(
'
snake_case
'
)).
toBe
(
'
snakeCase
'
);
});
});
});
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