fix: replace . with - in slugs (#39168)
This commit is contained in:
		
				
					committed by
					
						
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							7ed1d52001
						
					
				
				
					commit
					52ecb14b0f
				
			@@ -2,7 +2,7 @@ exports.dasherize = function dasherize(name) {
 | 
			
		||||
  return ('' + name)
 | 
			
		||||
    .toLowerCase()
 | 
			
		||||
    .trim()
 | 
			
		||||
    .replace(/\s/g, '-')
 | 
			
		||||
    .replace(/\s|\./g, '-')
 | 
			
		||||
    .replace(/[^a-z\d\-.]/g, '');
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -14,12 +14,16 @@ describe('dasherize', () => {
 | 
			
		||||
    expect(dasherize('the space  between')).toBe('the-space--between');
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  it('converts dots to dashes', () => {
 | 
			
		||||
    expect(dasherize('the..dots.. between')).toBe('the--dots---between');
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  it('trims off surrounding whitespace', () => {
 | 
			
		||||
    expect(dasherize('  the space  between    ')).toBe('the-space--between');
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  it('removes everything except letters, numbers, - and .', () => {
 | 
			
		||||
    expect(dasherize('1a!"£$%^*()_+=-.b2')).toBe('1a-.b2');
 | 
			
		||||
  it('removes everything except letters, numbers and -', () => {
 | 
			
		||||
    expect(dasherize('1a!"£$%^*()_+=-.b2')).toBe('1a--b2');
 | 
			
		||||
  });
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user