Skip to content

Instantly share code, notes, and snippets.

@teamon
Created April 10, 2009 11:25
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save teamon/93045 to your computer and use it in GitHub Desktop.
Save teamon/93045 to your computer and use it in GitHub Desktop.
require 'iconv'
class String
def to_permalink
Iconv.iconv('ascii//translit//IGNORE', 'utf-8', self).first.gsub("'", "").gsub(/[^\x00-\x7F]+/, '').gsub(/[^a-zA-Z0-9-]+/, '-').gsub(/^-/, '').gsub(/-$/, '').downcase
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment