format_url 0.0.3 → 0.0.4
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 +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/format_url.rb +1 -1
- data/lib/format_url/model_additions.rb +2 -2
- data/lib/format_url/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49045f22f1b4dc6c38f7780afaccc6739a9e1d71
|
4
|
+
data.tar.gz: 89c09e88c6bf952c9b7cdbd48b07dc0cd42f0ccf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 997471c35942b28521716950e9c747b058d4b7e454d6cbb4e3f819544abe11fc2ec55732a9fd109e7dbff56d7212604ed9809910f8622f894eda70c2a35ea9f5
|
7
|
+
data.tar.gz: 1a2b2c53a816c8c1a5b7fb05c12a139b21e60659b4b11dcbe8fd0ce998eac10b7e2918b472c4ff8a3d844d26fc196524ac5830845122770b963233387daca159
|
data/CHANGELOG.md
CHANGED
data/lib/format_url.rb
CHANGED
@@ -4,7 +4,7 @@ require "format_url/railtie" if defined? Rails
|
|
4
4
|
|
5
5
|
module FormatUrl
|
6
6
|
def self.format_url(url)
|
7
|
-
if url.to_s !~ url_regexp && "http://#{url}" =~ url_regexp
|
7
|
+
if url && url.length > 0 && url.to_s !~ url_regexp && "http://#{url}" =~ url_regexp
|
8
8
|
"http://#{url}"
|
9
9
|
else
|
10
10
|
url
|
@@ -3,8 +3,8 @@ module FormatUrl
|
|
3
3
|
def format_url(attribute)
|
4
4
|
before_validation do
|
5
5
|
send("#{attribute}=", FormatUrl.format_url(send(attribute)))
|
6
|
-
end
|
7
|
-
validates_format_of attribute, with: FormatUrl.url_regexp, message: "is not a valid URL"
|
6
|
+
end if attribute
|
7
|
+
validates_format_of attribute, with: FormatUrl.url_regexp, message: "is not a valid URL", :allow_blank => true
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
data/lib/format_url/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: format_url
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Hopkinson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|