handle non strings passed to Page.cname
This commit is contained in:
+3
-1
@@ -202,7 +202,9 @@ module Gollum
|
|||||||
#
|
#
|
||||||
# Returns the String canonical name.
|
# Returns the String canonical name.
|
||||||
def self.cname(name)
|
def self.cname(name)
|
||||||
name.gsub(%r{[ /<>]}, '-')
|
name.respond_to?(:gsub) ?
|
||||||
|
name.gsub(%r{[ /<>]}, '-') :
|
||||||
|
''
|
||||||
end
|
end
|
||||||
|
|
||||||
# Convert a format Symbol into an extension String.
|
# Convert a format Symbol into an extension String.
|
||||||
|
|||||||
@@ -110,4 +110,9 @@ context "Page" do
|
|||||||
footer = @wiki.page("_Footer")
|
footer = @wiki.page("_Footer")
|
||||||
assert_nil footer.footer
|
assert_nil footer.footer
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "cannot convert non string to human readable page title" do
|
||||||
|
assert_equal '', Gollum::Page.cname(nil)
|
||||||
|
assert_equal '', Gollum::Page.cname(3)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user