FIX: proper regex for category slug validation

This commit is contained in:
Arpit Jalan 2016-01-07 12:06:45 +05:30
parent dcd0270d52
commit bfd21461df
1 changed files with 1 additions and 1 deletions

View File

@ -230,7 +230,7 @@ SQL
end end
# only allow to use category itself id. new_record doesn't have a id. # only allow to use category itself id. new_record doesn't have a id.
unless new_record? unless new_record?
match_id = /(\d+)-category/.match(self.slug) match_id = /^(\d+)-category/.match(self.slug)
errors.add(:slug, :invalid) if match_id && match_id[1] && match_id[1] != self.id.to_s errors.add(:slug, :invalid) if match_id && match_id[1] && match_id[1] != self.id.to_s
end end
end end