Sha256: 05d5fb7f153090e5989943621ece1dbe87fa3fffe3a2150e187af5e1052b7415

Contents?: true

Size: 275 Bytes

Versions: 5

Compression:

Stored size: 275 Bytes

Contents

class String
  def to_permalink
    str = ActiveSupport::Multibyte::Chars.new(self)
    str = str.normalize(:kd).gsub(/[^\x00-\x7F]/,'').to_s
    str.gsub!(/[^-\w\d]+/sim, "-")
    str.gsub!(/-+/sm, "-")
    str.gsub!(/^-?(.*?)-?$/, '\1')
    str.downcase!
    str
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
permalink-1.1.1 lib/permalink/string_ext.rb
permalink-1.1.0 lib/permalink/string_ext.rb
permalink-1.0.0 lib/permalink/string_ext.rb
permalink-0.1.1 lib/permalink/string_ext.rb
permalink-0.1.0 lib/permalink/string_ext.rb