jekyll_href 1.2.3 → 1.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f273b4ad20431d42f67bd6a8bba43823e158b4239d385951371e5511f31483f6
4
- data.tar.gz: 13ce74af244bd5d9d26c44a7ebeb340126f729f084cddf04c75d0b79e83e973e
3
+ metadata.gz: 13925ae2b44abe077101e5302d6aee8a640cdf3c50dcb4a29c76e2c355dae039
4
+ data.tar.gz: cf41c3a1c8424fc3e3ba67ccf6f27238e71766c72ed7006442291d855a933c4f
5
5
  SHA512:
6
- metadata.gz: 69169786943109c5f2fb288a430d247f8fa3a46b4d94c78607c012f3a9abd4116f38e66a4071e11c8bb53e8d21e7b3efe716aaf32d7a93c73d670026a24038bc
7
- data.tar.gz: b37d5401822827f70f9b1e00f5eef1e93f8cab00c97a808409d71e6f173d99c0dc7bab5e33c07c2e41b98d47a2749a2e9e771588f167c8b269fa50b07c47cc96
6
+ metadata.gz: afa3c62bf2806362a3e52d6978a8ea9ad3b5eb21e5f685b5328c04c0e19728e680a58961bd0daac805fcfbef1f031e98c6de769b085c9c8e4f058a209793c325
7
+ data.tar.gz: ce210b8cecefb1282991e9f4cca6ca5f80e7d94b9738f875f4848e9c445e24744e57c5a93f099e83362ed6e10448a38499f1907b96a04ef402db63710589f2aa
data/.rubocop.yml CHANGED
@@ -64,7 +64,7 @@ Metrics/MethodLength:
64
64
  Max: 40
65
65
 
66
66
  Metrics/PerceivedComplexity:
67
- Max: 15
67
+ Max: 20
68
68
 
69
69
  Naming/FileName:
70
70
  Exclude:
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 1.2.4 / 2023-05-18
2
+ * When only a URI is provided, the plugin now generates the `http` scheme for IP4 & IP6 loopback addresses like
3
+ `localhost`, and `127.0.0.0`, as well as private IP4 addresses like 192.168.0.0 and 172.16.0.0;
4
+ otherwise it generates the `https` scheme.
5
+
1
6
  ## 1.2.3 / 2023-05-16
2
7
  * Added `label` option.
3
8
 
data/jekyll_href.gemspec CHANGED
@@ -28,9 +28,9 @@ Gem::Specification.new do |spec|
28
28
  spec.require_paths = ['lib']
29
29
  spec.required_ruby_version = '>= 2.6.0'
30
30
  spec.summary = "Generates an 'a href' tag, possibly with target='_blank' and rel='nofollow'."
31
- spec.test_files = spec.files.grep(%r!^(test|spec|features)/!)
32
31
  spec.version = JekyllHrefVersion::VERSION
33
32
 
33
+ spec.add_dependency 'ipaddress'
34
34
  spec.add_dependency 'jekyll', '>= 3.5.0'
35
35
  spec.add_dependency 'jekyll_all_collections', '~> 0.3.0', '>= 0.3.1'
36
36
  spec.add_dependency 'jekyll_plugin_support', '~> 0.6.0', '>= 0.6.1'
data/lib/href_tag.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'ipaddress'
1
2
  require 'jekyll_all_collections'
2
3
  require 'jekyll_plugin_logger'
3
4
  require 'jekyll_plugin_support'
@@ -151,7 +152,13 @@ module HrefTag
151
152
  text = linkk.gsub('/', '/­') if @shy
152
153
  text = linkk.gsub('/', '/<wbr>') if @wbr
153
154
  @text = "<code>#{text}</code>"
154
- @link = linkk.start_with?('http') ? linkk : "https://#{linkk}"
155
+ @link = if linkk.start_with?('http')
156
+ linkk
157
+ elsif insecure_ip_address linkk
158
+ "http://#{linkk}"
159
+ else
160
+ "https://#{linkk}"
161
+ end
155
162
  else
156
163
  @link = if @shy
157
164
  linkk.gsub('/', '/&shy;')
@@ -210,6 +217,19 @@ module HrefTag
210
217
  end
211
218
  end
212
219
 
220
+ def insecure_ip_address(string)
221
+ return true if string.start_with? 'localhost'
222
+
223
+ return false unless IPAddress.valid? string
224
+
225
+ ip_address = IPAddress string
226
+ return true if ip_address.loopback? || ip_address.private?
227
+ rescue StandardError
228
+ false
229
+ ensure
230
+ false
231
+ end
232
+
213
233
  # Replace names in plugin-vars with values
214
234
  def replace_vars(text)
215
235
  variables = @site.config['plugin-vars']
@@ -1,3 +1,3 @@
1
1
  module JekyllHrefVersion
2
- VERSION = '1.2.3'.freeze
2
+ VERSION = '1.2.4'.freeze
3
3
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll_href
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Slinn
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-17 00:00:00.000000000 Z
11
+ date: 2023-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ipaddress
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: jekyll
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -119,9 +133,5 @@ rubygems_version: 3.3.3
119
133
  signing_key:
120
134
  specification_version: 4
121
135
  summary: Generates an 'a href' tag, possibly with target='_blank' and rel='nofollow'.
122
- test_files:
123
- - spec/hash_array_spec.rb
124
- - spec/href_spec.rb
125
- - spec/spec_helper.rb
126
- - spec/status_persistence.txt
136
+ test_files: []
127
137
  ...