Skip to content

Instantly share code, notes, and snippets.

@sandcastle
Created February 9, 2014 00:45
Show Gist options
  • Save sandcastle/8892566 to your computer and use it in GitHub Desktop.
Save sandcastle/8892566 to your computer and use it in GitHub Desktop.
Converts a company name into a site slug - for SaaS applications.
/**
* 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, '');
};
@sandcastle
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment