Sha256: d203806e0f13aa6507f877b2eb11be5b8ad7f8c585c4e4f17110ee290736df2a
Contents?: true
Size: 523 Bytes
Versions: 17
Compression:
Stored size: 523 Bytes
Contents
# frozen_string_literal: true module Uffizzi module ProjectHelper SLUG_ENDING_LENGTH = 6 class << self def generate_slug(name) formatted_name = name.downcase.gsub(/ /, '-').gsub(/[^\w-]+/, '') slug_ending = generate_random_string(SLUG_ENDING_LENGTH) "#{formatted_name}-#{slug_ending}" end private def generate_random_string(length) hexatridecimal_base = 36 rand(hexatridecimal_base**length).to_s(hexatridecimal_base) end end end end
Version data entries
17 entries across 17 versions & 1 rubygems