Skip to content

Commit 52ecb14

Browse files
fix: replace . with - in slugs (freeCodeCamp#39168)
1 parent 7ed1d52 commit 52ecb14

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

utils/slugs.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ exports.dasherize = function dasherize(name) {
22
return ('' + name)
33
.toLowerCase()
44
.trim()
5-
.replace(/\s/g, '-')
5+
.replace(/\s|\./g, '-')
66
.replace(/[^a-z\d\-.]/g, '');
77
};
88

utils/slugs.test.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,16 @@ describe('dasherize', () => {
1414
expect(dasherize('the space between')).toBe('the-space--between');
1515
});
1616

17+
it('converts dots to dashes', () => {
18+
expect(dasherize('the..dots.. between')).toBe('the--dots---between');
19+
});
20+
1721
it('trims off surrounding whitespace', () => {
1822
expect(dasherize(' the space between ')).toBe('the-space--between');
1923
});
2024

21-
it('removes everything except letters, numbers, - and .', () => {
22-
expect(dasherize('1a!"£$%^*()_+=-.b2')).toBe('1a-.b2');
25+
it('removes everything except letters, numbers and -', () => {
26+
expect(dasherize('1a!"£$%^*()_+=-.b2')).toBe('1a--b2');
2327
});
2428
});
2529

0 commit comments

Comments
 (0)