lib/gollum/page.rb in gollum-2.1.6 vs lib/gollum/page.rb in gollum-2.1.7
- old
+ new
@@ -325,11 +325,11 @@
# # => 'Bilbo_Baggins'
#
# Returns the String canonical name.
def self.cname(name, char_white_sub = '-', char_other_sub = '-')
name.respond_to?(:gsub) ?
- name.gsub(%r{\s},char_white_sub).gsub(%r{[/<>+]}, char_other_sub) :
+ name.gsub(%r{\s},char_white_sub).gsub(%r{[<>+]}, char_other_sub) :
''
end
# Convert a format Symbol into an extension String.
#
@@ -370,13 +370,13 @@
#
# name - The human or canonical String page name to find.
# version - The String version ID to find.
#
# Returns a Gollum::Page or nil if the page could not be found.
- def find(name, version, dir = nil)
+ def find(name, version, dir = nil, exact = false)
map = @wiki.tree_map_for(version.to_s)
- if page = find_page_in_tree(map, name, dir)
+ if page = find_page_in_tree(map, name, dir, exact)
page.version = version.is_a?(Grit::Commit) ?
version : @wiki.commit_for(version)
page.historical = page.version.to_s == version.to_s
page
end
@@ -389,14 +389,16 @@
# name - The canonical String page name.
# checked_dir - Optional String of the directory a matching page needs
# to be in. The string should
#
# Returns a Gollum::Page or nil if the page could not be found.
- def find_page_in_tree(map, name, checked_dir = nil)
+ def find_page_in_tree(map, name, checked_dir = nil, exact = false)
return nil if !map || name.to_s.empty?
if checked_dir = BlobEntry.normalize_dir(checked_dir)
checked_dir.downcase!
end
+
+ checked_dir = '' if exact && checked_dir.nil?
map.each do |entry|
next if entry.name.to_s.empty?
next unless checked_dir.nil? || entry.dir.downcase == checked_dir
next unless page_match(name, entry.name)