validate_url 1.0.8 → 1.0.13

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
- SHA1:
3
- metadata.gz: e2f24b722e790d48ad428b1d8249bc7782770a38
4
- data.tar.gz: a63f7504960fede22e2d179a9dddab4e35cf30e3
2
+ SHA256:
3
+ metadata.gz: 414a69dd5d0048f3563cafe2136e4b4c00731d4492afa77b4c9248bcd91f24d2
4
+ data.tar.gz: b92e07f5bdb42ff396395fd1adf40473ff08a4781397357cd752dbbbcb198523
5
5
  SHA512:
6
- metadata.gz: 152ed2ee4b0e25d6425e58a7e802389a98b2eadd10b511c81fa02c8e164d212553eb2eccd71e0dbbd39d58dd3807a7e7f9501c5fbb82ea9e7d3f4877349521cc
7
- data.tar.gz: 2e96898b898c4c7f675dc81577cf81ae0b22910278ac036088a5db86f4d0b3f5ce05001c0a59c38c01a4337c1fb1f143df24398e9c34f2beef52154765062777
6
+ metadata.gz: e3bbe821276bf8f2c82e227a2b0c9bcb9aa76782994da820977a992e7bb0d9116a623d421e1850713cd8dfed91b22620c2d9bcd6d30770e1d198bf8486a13992
7
+ data.tar.gz: 07bf30ca4b67f8701baacd6505a3c9f64d792267cca3f672832b927e5f1df331ba32881faee2d755aa01abd92c7bbefde91795df3fd5da0246a8b82ed94fbd82
data/README.md CHANGED
@@ -8,7 +8,7 @@ This gem adds the capability of validating URLs to ActiveRecord and ActiveModel.
8
8
  # add this to your Gemfile
9
9
  gem "validate_url"
10
10
 
11
- # and run
11
+ # or run
12
12
  sudo gem install validate_url
13
13
  ```
14
14
 
@@ -51,6 +51,22 @@ class Unicorn
51
51
  end
52
52
  ```
53
53
 
54
+ ### With RSpec
55
+
56
+ Require the matcher in `spec_helper.rb` or `rails_helper.rb`:
57
+
58
+ ```ruby
59
+ require 'validate_url/rspec_matcher'
60
+ ```
61
+
62
+ In your spec:
63
+
64
+ ```ruby
65
+ describe Unicorn
66
+ it { is_expected.to validate_url_of(:homepage) }
67
+ end
68
+ ```
69
+
54
70
  ### I18n
55
71
 
56
72
  The default error message `is not a valid URL`.
@@ -70,3 +86,15 @@ Validates URL is created and maintained by [PerfectLine](http://www.perfectline.
70
86
 
71
87
  Validates URL is Copyright © 2010-2014 [PerfectLine](http://www.perfectline.co), LLC. It is free software, and may be
72
88
  redistributed under the terms specified in the LICENSE file.
89
+
90
+ ## How to push new version
91
+
92
+ ```
93
+ rake version:bump:patch
94
+ rake gemspec
95
+ ```
96
+ Fix validate_url.gemspec to remove unneeded wrong strings
97
+ ```
98
+ gem build validate_url.gemspec
99
+ gem push validate_url-1.0.8.gem
100
+ ```
@@ -0,0 +1,4 @@
1
+ ar:
2
+ errors:
3
+ messages:
4
+ url: عنوان الموقع غير صالح
@@ -0,0 +1,4 @@
1
+ es:
2
+ errors:
3
+ messages:
4
+ url: no es una URL válida
@@ -1,4 +1,4 @@
1
1
  ja:
2
2
  errors:
3
3
  messages:
4
- url: は不正なURLです。
4
+ url: は不正なURLです
@@ -0,0 +1,4 @@
1
+ vi:
2
+ errors:
3
+ messages:
4
+ url: không phải là một địa chỉ liên kết hợp lệ
@@ -20,20 +20,20 @@ module ActiveModel
20
20
  def validate_each(record, attribute, value)
21
21
  schemes = [*options.fetch(:schemes)].map(&:to_s)
22
22
  begin
23
- escaped_uri = value ? URI.escape(value) : nil
24
- uri = URI.parse(escaped_uri)
23
+ uri = URI.parse(value)
25
24
  host = uri && uri.host
26
25
  scheme = uri && uri.scheme
27
26
 
28
- valid_suffix = !options.fetch(:public_suffix) || (host && PublicSuffix.valid?(host, :default_rule => nil))
29
- valid_no_local = !options.fetch(:no_local) || (host && host.include?('.'))
27
+ valid_raw_url = scheme && value =~ /\A#{URI::regexp([scheme])}\z/
30
28
  valid_scheme = host && scheme && schemes.include?(scheme)
29
+ valid_no_local = !options.fetch(:no_local) || (host && host.include?('.'))
30
+ valid_suffix = !options.fetch(:public_suffix) || (host && PublicSuffix.valid?(host, :default_rule => nil))
31
31
 
32
- unless valid_scheme && valid_no_local && valid_suffix
32
+ unless valid_raw_url && valid_scheme && valid_no_local && valid_suffix
33
33
  record.errors.add(attribute, options.fetch(:message), value: value)
34
34
  end
35
35
  rescue URI::InvalidURIError
36
- record.errors.add(attribute, :url, filtered_options(value))
36
+ record.errors.add(attribute, :url, **filtered_options(value))
37
37
  end
38
38
  end
39
39
 
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validate_url
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tanel Suurhans
8
8
  - Tarmo Lehtpuu
9
9
  - Vladimir Krylov
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2019-04-03 00:00:00.000000000 Z
13
+ date: 2020-09-23 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: jeweler
@@ -125,8 +125,10 @@ files:
125
125
  - README.md
126
126
  - init.rb
127
127
  - install.rb
128
+ - lib/locale/ar.yml
128
129
  - lib/locale/de.yml
129
130
  - lib/locale/en.yml
131
+ - lib/locale/es.yml
130
132
  - lib/locale/fr.yml
131
133
  - lib/locale/it.yml
132
134
  - lib/locale/ja.yml
@@ -136,14 +138,15 @@ files:
136
138
  - lib/locale/ro.yml
137
139
  - lib/locale/ru.yml
138
140
  - lib/locale/tr.yml
141
+ - lib/locale/vi.yml
139
142
  - lib/locale/zh-CN.yml
140
143
  - lib/locale/zh-TW.yml
141
- - lib/rspec_matcher.rb
142
144
  - lib/validate_url.rb
145
+ - lib/validate_url/rspec_matcher.rb
143
146
  homepage: http://github.com/perfectline/validates_url/tree/master
144
147
  licenses: []
145
148
  metadata: {}
146
- post_install_message:
149
+ post_install_message:
147
150
  rdoc_options: []
148
151
  require_paths:
149
152
  - lib
@@ -158,9 +161,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
161
  - !ruby/object:Gem::Version
159
162
  version: '0'
160
163
  requirements: []
161
- rubyforge_project:
162
- rubygems_version: 2.4.5.1
163
- signing_key:
164
+ rubygems_version: 3.0.8
165
+ signing_key:
164
166
  specification_version: 4
165
167
  summary: Library for validating urls in Rails.
166
168
  test_files: []