Sha256: 938b092783f3534aa44e8bcb1ce9775ffaef9e5eb33e3fa2908eee69304abfd1
Contents?: true
Size: 660 Bytes
Versions: 19
Compression:
Stored size: 660 Bytes
Contents
# frozen_string_literal: true module PagesCore module HumanizableParam include ActiveSupport::Inflector extend ActiveSupport::Concern def humanized_param(slug) safe_slug = safe_humanized_param(slug) return id.to_s if safe_slug.blank? "#{id}-#{safe_slug}" end private def safe_humanized_param(str) transliterate(str.to_s).downcase .gsub(/[\[{]/, "(") .gsub(/}\]/, ")") .gsub(/[^[[:alnum:]]()-]+/, "-") .gsub(/-{2,}/, "-") .gsub(/(^-|-$)/, "") end end end
Version data entries
19 entries across 19 versions & 1 rubygems