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
04a29b1b
Commit
04a29b1b
authored
Nov 12, 2019
by
Arun Kumar Mohan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove duplication from slugifyWithUnderscore function
parent
9faa870e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
7 deletions
+13
-7
app/assets/javascripts/lib/utils/text_utility.js
app/assets/javascripts/lib/utils/text_utility.js
+8
-7
changelogs/unreleased/chore-slugify-duplication-removal.yml
changelogs/unreleased/chore-slugify-duplication-removal.yml
+5
-0
No files found.
app/assets/javascripts/lib/utils/text_utility.js
View file @
04a29b1b
...
...
@@ -36,25 +36,26 @@ export const humanize = string =>
export
const
dasherize
=
str
=>
str
.
replace
(
/
[
_
\s]
+/g
,
'
-
'
);
/**
* Replaces whitespaces with hyphens, convert to lower case and remove non-allowed special characters
* @param {String} str
* Replaces whitespace and non-sluggish characters with a given separator
* @param {String} str - The string to slugify
* @param {String=} separator - The separator used to separate words (defaults to "-")
* @returns {String}
*/
export
const
slugify
=
str
=>
{
export
const
slugify
=
(
str
,
separator
=
'
-
'
)
=>
{
const
slug
=
str
.
trim
()
.
toLowerCase
()
.
replace
(
/
[^
a-zA-Z0-9_.-
]
+/g
,
'
-
'
);
.
replace
(
/
[^
a-zA-Z0-9_.-
]
+/g
,
separator
);
return
slug
===
'
-
'
?
''
:
slug
;
return
slug
===
separator
?
''
:
slug
;
};
/**
* Replaces whitespace
s with underscore and converts to lower case
* Replaces whitespace
and non-sluggish characters with underscores
* @param {String} str
* @returns {String}
*/
export
const
slugifyWithUnderscore
=
str
=>
s
tr
.
toLowerCase
().
replace
(
/
\s
+/g
,
'
_
'
);
export
const
slugifyWithUnderscore
=
str
=>
s
lugify
(
str
,
'
_
'
);
/**
* Truncates given text
...
...
changelogs/unreleased/chore-slugify-duplication-removal.yml
0 → 100644
View file @
04a29b1b
---
title
:
Remove duplication from slugifyWithUnderscore function
merge_request
:
20016
author
:
Arun Kumar Mohan
type
:
other
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