auto_html 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/auto_html/link.rb +7 -2
- data/spec/auto_html/link_spec.rb +11 -0
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c4554b35676a92a446754ad032d363e1f4be41613ae4923f376ddbb8229a334
|
4
|
+
data.tar.gz: 32062562a065326482d93d164caa849ff81029eb872ee66d973d435e528f99bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f22718875cce1764c67e795badf8dca2596697d22e9cd3b31d08b71a2abfe0d2b1c726eefee905b263ecf7352cb2e12c5a8aae4fbc1808e1169b45e2f350e3a2
|
7
|
+
data.tar.gz: ad11106a8df96b900a20df3a0665ec7b9227ba8a92a1728725381d540a11c8df41057dba72feeb9f22fefab82749336038d74c4bd6efa718d263da440eb82452
|
data/README.md
CHANGED
data/lib/auto_html/link.rb
CHANGED
@@ -7,13 +7,14 @@ require 'rexml/document'
|
|
7
7
|
module AutoHtml
|
8
8
|
# Link filter
|
9
9
|
class Link
|
10
|
-
def initialize(target: nil, rel: nil)
|
10
|
+
def initialize(target: nil, rel: nil, short_domains: false)
|
11
11
|
@target = target
|
12
12
|
@rel = rel
|
13
|
+
@short_domains = short_domains
|
13
14
|
end
|
14
15
|
|
15
16
|
def call(text)
|
16
|
-
Rinku.auto_link(text, :all, attributes)
|
17
|
+
Rinku.auto_link(text, :all, attributes, nil, flags)
|
17
18
|
end
|
18
19
|
|
19
20
|
private
|
@@ -29,5 +30,9 @@ module AutoHtml
|
|
29
30
|
def target_attr
|
30
31
|
%(target="#{@target}") if @target
|
31
32
|
end
|
33
|
+
|
34
|
+
def flags
|
35
|
+
@short_domains ? Rinku::AUTOLINK_SHORT_DOMAINS : 0
|
36
|
+
end
|
32
37
|
end
|
33
38
|
end
|
data/spec/auto_html/link_spec.rb
CHANGED
@@ -33,6 +33,11 @@ RSpec.describe AutoHtml::Link do
|
|
33
33
|
expect(result).to eq '<a href="http://www.google.com/#q=nikola+tesla&ct=tesla09&oi=ddle&fp=Xmf0jJ9P_V0">http://www.google.com/#q=nikola+tesla&ct=tesla09&oi=ddle&fp=Xmf0jJ9P_V0</a>'
|
34
34
|
end
|
35
35
|
|
36
|
+
it 'not transforms short domain URL' do
|
37
|
+
result = subject.call('http://localhost:3000')
|
38
|
+
expect(result).to eq 'http://localhost:3000'
|
39
|
+
end
|
40
|
+
|
36
41
|
it 'transforms with target options' do
|
37
42
|
filter = described_class.new(target: '_blank')
|
38
43
|
result = filter.call('http://rors.org')
|
@@ -45,6 +50,12 @@ RSpec.describe AutoHtml::Link do
|
|
45
50
|
expect(result).to eq '<a href="http://rors.org" rel="nofollow">http://rors.org</a>'
|
46
51
|
end
|
47
52
|
|
53
|
+
it 'transforms with short_domains options' do
|
54
|
+
filter = described_class.new(short_domains: true)
|
55
|
+
result = filter.call('http://localhost:3000')
|
56
|
+
expect(result).to eq '<a href="http://localhost:3000">http://localhost:3000</a>'
|
57
|
+
end
|
58
|
+
|
48
59
|
it 'transforms with target and rel options' do
|
49
60
|
filter = described_class.new(target: '_blank', rel: 'nofollow')
|
50
61
|
result = filter.call('http://rors.org')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: auto_html
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dejan Simic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gemoji
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '3.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rexml
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.2.5
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.2.5
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rinku
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -154,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
154
168
|
- !ruby/object:Gem::Version
|
155
169
|
version: '0'
|
156
170
|
requirements: []
|
157
|
-
rubygems_version: 3.2.
|
171
|
+
rubygems_version: 3.2.3
|
158
172
|
signing_key:
|
159
173
|
specification_version: 4
|
160
174
|
summary: Plain text to HTML conversion
|