Skip to content

Instantly share code, notes, and snippets.

@teamon
Created April 10, 2009 11:25
Show Gist options
  • Select an option

  • Save teamon/93045 to your computer and use it in GitHub Desktop.

Select an option

Save teamon/93045 to your computer and use it in GitHub Desktop.

Revisions

  1. teamon created this gist Apr 10, 2009.
    6 changes: 6 additions & 0 deletions snippet.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    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