Sha256: f24ac4d46a389004bb4d77861e23d75689828f64a4d0c464149be087f634445d
Contents?: true
Size: 1.1 KB
Versions: 7
Compression:
Stored size: 1.1 KB
Contents
# ~*~ encoding: utf-8 ~*~ module Precious module Helpers # Extract the path string that Gollum::Wiki expects def extract_path(file_path) return nil if file_path.nil? last_slash = file_path.rindex("/") if last_slash file_path[0, last_slash] end end # Extract the 'page' name from the file_path def extract_name(file_path) if file_path[-1, 1] == "/" return nil end # File.basename is too eager to please and will return the last # component of the path even if it ends with a directory separator. ::File.basename(file_path) end def sanitize_empty_params(param) [nil,''].include?(param) ? nil : CGI.unescape(param) end # Ensure path begins with a single leading slash def clean_path(path) if path (path[0] != '/' ? path.insert(0, '/') : path).gsub(/\/{2,}/,'/') end end # Remove all slashes from the start of string. # Remove all double slashes def clean_url url return url if url.nil? url.gsub('%2F','/').gsub(/^\/+/,'').gsub('//','/') end end end
Version data entries
7 entries across 7 versions & 1 rubygems