Sha256: 46f6b0b6694d1ac16f999b9ae2284bf0b3523a3f7bf7118b645260538cc16a34
Contents?: true
Size: 615 Bytes
Versions: 9
Compression:
Stored size: 615 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, ::File.extname(str)) end end end
Version data entries
9 entries across 9 versions & 1 rubygems