url_format 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a9ab1011a61bbac549072914ab54f74cefff6ad7
4
- data.tar.gz: 88d1ed28e9763fa531589fded708b0a311b7f844
3
+ metadata.gz: 1805e62ee4b7a41087fe084c7602dbb8d7514910
4
+ data.tar.gz: 9ca2331032efbac625d71ad10ef30350dff9e79d
5
5
  SHA512:
6
- metadata.gz: 342caa41756703d9f1578a9b622f2bcfa4b5ade5324014aed5a9cc461da80186072df13d295f9697ab398044f82183346154dd7968f0172961cc591da9b5982b
7
- data.tar.gz: 45a42f051194e50f89c760759cbed46bd1b38dedd458202482b41c426e05241c6606ec42c85d1069a2e73ea3e2ffe2774e94881b82663da39f82adf1d5fa9a33
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
- record.send("#{attribute}=","http://#{value}") unless value =~ /\Ahttps?:\/\//
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
@@ -1,3 +1,3 @@
1
1
  module UrlFormat
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: url_format
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Otander