File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ class Page < ActiveRecord::Base
6161
6262 has_many :tasks
6363
64- before_validation :append_leading_slash_to_path
64+ before_validation :append_leading_slash_to_path , :remove_trailing_slash_from_path
6565 before_destroy :delete_connectors
6666
6767 validates_presence_of :name , :path
@@ -218,6 +218,12 @@ def append_leading_slash_to_path
218218 self . path = "/#{ path } "
219219 end
220220 end
221+
222+ # remove trailing slash, unless the path is only a slash. uses capture and
223+ # substition because ruby regex engine does not support lookbehind
224+ def remove_trailing_slash_from_path
225+ self . path . sub! ( /(.+)\/ +$/ , '\1' )
226+ end
221227
222228 def path_not_reserved
223229 if Cms . reserved_paths . include? ( path )
You can’t perform that action at this time.
0 commit comments