bypass 0.0.2 → 0.0.3
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 +8 -8
- data/.travis.yml +1 -5
- data/lib/bypass/filter.rb +6 -0
- data/lib/bypass/html_filter.rb +4 -2
- data/lib/bypass/text_filter.rb +4 -2
- data/lib/bypass/version.rb +1 -1
- data/test/{detour → bypass}/filter_test.rb +0 -0
- data/test/{detour → bypass}/html_filter_test.rb +7 -0
- data/test/{detour → bypass}/text_filter_test.rb +7 -0
- data/test/{detour → bypass}/uri_test.rb +0 -0
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MGE5YjdiM2QyNTc1MTM4MzQ3NGVhODRmM2ZiM2ZhMDAzYmZjZTVhZg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MGU0ODk2YmVmN2Q3ZjNiNjZiZGI3YmNlYjNlYmVlYzYzZjY0NTA2Yw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NzY2NjUzNDJjYjE3MzBjYzY1ZjQ5NTQ0NGY3ZjFhM2I2YWMyYjYxNWI5MTU3
|
10
|
+
OWNmMzMxMTFhZWI3NzRjNjFiZWUwNjZiNGUyMzc3ZDNiMDA1MzQ5ZmRiMGEy
|
11
|
+
MGE2OWUwY2E5NWJkMjdmYzFjYWI1MTM1OTY4NzQ2YjYwMjA3MDU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YTNmZTcyMzFmMmMxYmNlOTgwZjRiZWI3YjQwM2IwY2ZjMDlmMzU1NjVjMjcz
|
14
|
+
YWU0MGE4OWVhZTY5ODY3Njg3OWIyMDkzMGNmZTg4YmViNWEyYzhhNThiMWQ3
|
15
|
+
NDkyZGE2NDllNzc3OGU2NmMyMjE2ZTI1MTIyZWYzNGU5OTU5Yzg=
|
data/.travis.yml
CHANGED
data/lib/bypass/filter.rb
CHANGED
data/lib/bypass/html_filter.rb
CHANGED
@@ -6,8 +6,10 @@ module Bypass
|
|
6
6
|
def replace(&block)
|
7
7
|
parsed_content.traverse do |node|
|
8
8
|
if node.name == "a" && href = node.get_attribute("href")
|
9
|
-
|
10
|
-
|
9
|
+
if parsed_href = parse_uri(href)
|
10
|
+
url = yield(parsed_href)
|
11
|
+
node.set_attribute("href", url.to_s)
|
12
|
+
end
|
11
13
|
end
|
12
14
|
end
|
13
15
|
end
|
data/lib/bypass/text_filter.rb
CHANGED
@@ -2,8 +2,10 @@ module Bypass
|
|
2
2
|
class TextFilter < Filter
|
3
3
|
|
4
4
|
def replace(&block)
|
5
|
-
@content = gsub_urls(content) do |url|
|
6
|
-
|
5
|
+
@content = gsub_urls(content) do |url|
|
6
|
+
if parsed_url = parse_uri(url)
|
7
|
+
yield(parsed_url).to_s
|
8
|
+
end
|
7
9
|
end
|
8
10
|
end
|
9
11
|
|
data/lib/bypass/version.rb
CHANGED
File without changes
|
@@ -16,6 +16,13 @@ class Bypass::HTMLFilterTest < Test::Unit::TestCase
|
|
16
16
|
filter.replace { "foo" }
|
17
17
|
assert_equal "<a>Yahoo</a>", filter.content
|
18
18
|
end
|
19
|
+
|
20
|
+
should "skip malformed URLs" do
|
21
|
+
text = "<a href=\"http://#\">Yahoo</a>"
|
22
|
+
filter = Bypass::HTMLFilter.new(text)
|
23
|
+
filter.replace { "foo" }
|
24
|
+
assert_equal text, filter.content
|
25
|
+
end
|
19
26
|
end
|
20
27
|
|
21
28
|
context "#auto_link" do
|
@@ -30,5 +30,12 @@ class Bypass::TextFilterTest < Test::Unit::TestCase
|
|
30
30
|
filter.replace { "foo" }
|
31
31
|
assert_equal "foo,", filter.content
|
32
32
|
end
|
33
|
+
|
34
|
+
should "skip malformed URLs" do
|
35
|
+
text = "http://#"
|
36
|
+
filter = Bypass::TextFilter.new(text)
|
37
|
+
filter.replace { "foo" }
|
38
|
+
assert_equal text, filter.content
|
39
|
+
end
|
33
40
|
end
|
34
41
|
end
|
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bypass
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Derrick Reimer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -86,10 +86,10 @@ files:
|
|
86
86
|
- lib/bypass/text_filter.rb
|
87
87
|
- lib/bypass/uri.rb
|
88
88
|
- lib/bypass/version.rb
|
89
|
-
- test/
|
90
|
-
- test/
|
91
|
-
- test/
|
92
|
-
- test/
|
89
|
+
- test/bypass/filter_test.rb
|
90
|
+
- test/bypass/html_filter_test.rb
|
91
|
+
- test/bypass/text_filter_test.rb
|
92
|
+
- test/bypass/uri_test.rb
|
93
93
|
- test/test_helper.rb
|
94
94
|
homepage: https://github.com/djreimer/bypass
|
95
95
|
licenses: []
|
@@ -115,8 +115,8 @@ signing_key:
|
|
115
115
|
specification_version: 4
|
116
116
|
summary: Mutate URLs and hyperlinks in HTML and plain text documents with ease
|
117
117
|
test_files:
|
118
|
-
- test/
|
119
|
-
- test/
|
120
|
-
- test/
|
121
|
-
- test/
|
118
|
+
- test/bypass/filter_test.rb
|
119
|
+
- test/bypass/html_filter_test.rb
|
120
|
+
- test/bypass/text_filter_test.rb
|
121
|
+
- test/bypass/uri_test.rb
|
122
122
|
- test/test_helper.rb
|