Sha256: 78ad6a66a3494821dc0af8058cfd221463a0157319ba60963b265b8be5e801f3
Contents?: true
Size: 649 Bytes
Versions: 22
Compression:
Stored size: 649 Bytes
Contents
# ~*~ encoding: utf-8 ~*~ module Gollum module Helpers # If url starts with a leading slash, trim down its number of leading slashes to 1. Else, return url unchanged. def trim_leading_slashes(url) return nil if url.nil? url.gsub!('%2F', '/') return '/' + url.gsub(/^\/+/, '') if url[0, 1] == '/' url end # Take a link path and turn it into a string for display as link text. # For example: # '/opt/local/bin/ruby.ext' -> 'ruby' def path_to_link_text(str) return nil unless str ::File.basename(str, Page.valid_extension?(str) ? ::File.extname(str) : '') end end end
Version data entries
22 entries across 22 versions & 1 rubygems