OSDN Git Service

Use URI::regexp for validating WebHook urls
authorAriejan de Vroom <ariejan@ariejan.net>
Mon, 26 Dec 2011 09:12:09 +0000 (10:12 +0100)
committerAriejan de Vroom <ariejan@ariejan.net>
Mon, 26 Dec 2011 09:12:09 +0000 (10:12 +0100)
app/models/web_hook.rb

index 96684d1..0058bd5 100644 (file)
@@ -9,7 +9,7 @@ class WebHook < ActiveRecord::Base
   validates :url,
             presence: true,
             format: {
-              with: /(^$)|(^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$)/ix,
+              with: URI::regexp(%w(http https)),
               message: "should be a valid url" }
 
   def execute(data)