Fix page lookup. #473

This commit is contained in:
bootstraponline
2012-08-23 12:16:40 -06:00
parent b76257c49c
commit 01fa4770cb
+5 -2
View File
@@ -441,13 +441,16 @@ module Gollum
# Find a page from a given cname. If the page has an anchor (#) and has # Find a page from a given cname. If the page has an anchor (#) and has
# no match, strip the anchor and try again. # no match, strip the anchor and try again.
# #
# cname - The String canonical page name. # cname - The String canonical page name including path.
# #
# Returns a Gollum::Page instance if a page is found, or an Array of # Returns a Gollum::Page instance if a page is found, or an Array of
# [Gollum::Page, String extra] if a page without the extra anchor data # [Gollum::Page, String extra] if a page without the extra anchor data
# is found. # is found.
def find_page_from_name(cname) def find_page_from_name(cname)
if page = @wiki.page(cname) slash = cname.rindex('/')
name = cname[slash+1..-1]
path = cname[0..slash]
if page = @wiki.paged(name, path)
return page return page
end end
if pos = cname.index('#') if pos = cname.index('#')