Sha256: ff98f156e1e5e4ff1473bda6988eca0228830b80d77769abaa2c9f3a74fa9b4a

Contents?: true

Size: 298 Bytes

Versions: 8

Compression:

Stored size: 298 Bytes

Contents

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

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
permalink-1.3.0 lib/permalink/string_ext.rb
permalink-1.2.2 lib/permalink/string_ext.rb
permalinker-1.0.3 lib/permalinker/string_ext.rb
permalinker-1.0.2 lib/permalinker/string_ext.rb
permalinker-1.0.1 lib/permalinker/string_ext.rb
permalink-1.2.1 lib/permalink/string_ext.rb
permalink-1.2.0 lib/permalink/string_ext.rb
permalink-1.1.2 lib/permalink/string_ext.rb