Skip to content

Commit

Permalink
fix: link email validate format regex
Browse files Browse the repository at this point in the history
  • Loading branch information
sjdonado committed Jul 14, 2024
1 parent aeb6d11 commit 451a5fb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/controllers/link.cr
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module App::Controllers::Link
link.user = user

loop do
slug = Random::Secure.urlsafe_base64(4).gsub(/[^a-zA-Z0-9]/, "")
slug = Random::Secure.urlsafe_base64(5).gsub(/[^a-zA-Z0-9]/, "")
if !Database.get_by(Link, slug: slug)
link.slug = slug
break
Expand Down
2 changes: 1 addition & 1 deletion app/models/link.cr
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ module App::Models
unique_constraint :slug

validate_required [:slug, :url]
validate_format :url, /\A(?:https?:\/\/)?(?:[\w-]+\.)+[\w-]+(?:\/\S*)?/
validate_format :url, /\Ahttps?:\/\/(?:[\w.-]+)(?::\d+)?(?:[\/?#]\S*)?\z/i
end
end

0 comments on commit 451a5fb

Please sign in to comment.