url_format 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/url_format/url_format_validator.rb +3 -2
- data/lib/url_format/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1805e62ee4b7a41087fe084c7602dbb8d7514910
|
4
|
+
data.tar.gz: 9ca2331032efbac625d71ad10ef30350dff9e79d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b2414aa83d1919196a7e14cacc03b03600663864258e45920ac6cd55cfee80788368ea025f6b1d8f85a5077cff7b549d21e0f44306d81735bb85fed1c2d1743
|
7
|
+
data.tar.gz: e59d7902ea52328bcdeeaa147890c132f820d5dc8db09b4343505a47323db5125b15fbff2270e1abf3d10d1cf51389a92016ee1b51bec2b4bb7da35b7c19d5c4
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class UrlFormatValidator < ActiveModel::EachValidator
|
2
2
|
def validate_each(record, attribute, value)
|
3
|
-
format_value(record, attribute, value)
|
3
|
+
value = format_value(record, attribute, value)
|
4
4
|
unless URI.parse(value).kind_of?(URI::HTTP) && value =~ url_regexp
|
5
5
|
record.errors[attribute] << (options[:message] || "is invalid")
|
6
6
|
end
|
@@ -9,7 +9,8 @@ class UrlFormatValidator < ActiveModel::EachValidator
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def format_value(record, attribute, value)
|
12
|
-
|
12
|
+
return value if value =~ /\Ahttps?:\/\//
|
13
|
+
record.send("#{attribute}=","http://#{value}")
|
13
14
|
end
|
14
15
|
|
15
16
|
# Thanks to Dean Perry and Ryan Bates
|
data/lib/url_format/version.rb
CHANGED