Created
          February 9, 2014 00:45 
        
      - 
      
- 
        Save sandcastle/8892566 to your computer and use it in GitHub Desktop. 
    Converts a company name into a site slug - for SaaS applications.
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | /** | |
| * Converts a company name into a site slug. | |
| * @param {String} value | |
| * @returns {string} | |
| */ | |
| var createSlug = function(value) { | |
| if (_.isEmpty(value)) { //lodash call | |
| return ''; | |
| } | |
| return value | |
| .toLowerCase() | |
| .replace(/\s+/g, '-') | |
| .replace(/[^a-z0-9-]/g, '') | |
| .replace(/-+(pty|ltd|pty-ltd|plc|llc|inc|co)$/g, ''); | |
| }; | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
Types of business entities:
http://en.wikipedia.org/wiki/Types_of_business_entity