preadly-bulbasaur 0.5.0 → 0.6.0
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
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c7517dcff737c25c17adfa27642bca8ca1cd56e
|
4
|
+
data.tar.gz: 577969cc263ffc3fa5ddc98de2acf1a38e27e828
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e758c122332ab66128caf1a94ddce111ac1e634d84dd11bd3e7df68d76be3e340b4b51cfd392ff5ba43407ea5a4fd00c519ebd3801082d6d5aa112a9a91403b
|
7
|
+
data.tar.gz: ab56e8c804283854aedde3cf02851e5e3cc40b8e720c777955b6506fd776cbf618054bda87286a570ba272b9ac34110bf8741fc663fa3b8ba07f55a34c8246f2
|
@@ -3,7 +3,7 @@ module Bulbasaur
|
|
3
3
|
class ExtractImagesFromHTML
|
4
4
|
|
5
5
|
CSS_IMPORT_URL_REGEX = /(?<=url\()['"]?.+?['"]?.+?(?=\))/
|
6
|
-
IMG_CANDIDATE_URL_REGEX = /https?:\/\/\S*\.(?:png|jpg|jpeg|gif)(?!\.\S)/i
|
6
|
+
IMG_CANDIDATE_URL_REGEX = /https?:\/\/\S*\.(?:png|jpg|jpeg|gif)[(?:|~\w)]*(?!\.\S)/i
|
7
7
|
|
8
8
|
def initialize(html)
|
9
9
|
@html = html
|
data/lib/bulbasaur/version.rb
CHANGED
@@ -70,22 +70,39 @@ RSpec.describe Bulbasaur::ExtractImagesFromHTML do
|
|
70
70
|
<a href="http://somewhere.to/get/the_original_image.jpg?width=400&height=400">
|
71
71
|
Click here to see the original image.
|
72
72
|
</a>
|
73
|
+
<a href="http://somewhere.to/get/the_original_image.jpg~original">
|
74
|
+
Click here to see the original image.
|
75
|
+
</a>
|
76
|
+
<a href="http://somewhere.to/get/The_Original_Image%C3%A7a_3.JPG">
|
77
|
+
Click here to see the original image.
|
78
|
+
</a>
|
73
79
|
<a href="http://somewhere.to/go/to/another_page.html">
|
74
80
|
Click here to go to another page.
|
75
81
|
</a>
|
82
|
+
<a href="http://somewhere.to/get/the_original_image.jpg.exe">
|
83
|
+
Click here to get a virus.
|
84
|
+
</a>
|
76
85
|
</p>'
|
77
86
|
end
|
78
87
|
|
79
|
-
it 'Does return an image array with
|
80
|
-
expect(subject.size).to eq
|
88
|
+
it 'Does return an image array with 4 items' do
|
89
|
+
expect(subject.size).to eq 4
|
81
90
|
end
|
82
91
|
|
83
92
|
it 'Does return the image URL with parameters' do
|
84
|
-
expect(subject
|
93
|
+
expect(subject).to include Hash url: 'http://somewhere.to/get/the_original_image.jpg?width=400&height=400', alt: nil
|
85
94
|
end
|
86
95
|
|
87
96
|
it 'Does return the image URL without parameters' do
|
88
|
-
expect(subject
|
97
|
+
expect(subject).to include Hash url: 'http://somewhere.to/get/the_original_image.jpg', alt: nil
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'Does return the image URL with tilde parameters' do
|
101
|
+
expect(subject).to include Hash url: 'http://somewhere.to/get/the_original_image.jpg~original', alt: nil
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'Does return the image URL with upcased and special characters' do
|
105
|
+
expect(subject).to include Hash url: 'http://somewhere.to/get/The_Original_Image%C3%A7a_3.JPG', alt: nil
|
89
106
|
end
|
90
107
|
|
91
108
|
it 'Does return the image alt' do
|
@@ -93,9 +110,8 @@ RSpec.describe Bulbasaur::ExtractImagesFromHTML do
|
|
93
110
|
end
|
94
111
|
|
95
112
|
it 'Does not include links other than for images' do
|
96
|
-
expect(subject).
|
97
|
-
expect(subject).
|
98
|
-
expect(subject).not_to include Hash(url: 'http://somewhere.to/go/to/another_page.html', alt: nil)
|
113
|
+
expect(subject).not_to include Hash url: 'http://somewhere.to/get/the_original_image.jpg.exe', alt: nil
|
114
|
+
expect(subject).not_to include Hash url: 'http://somewhere.to/go/to/another_page.html', alt: nil
|
99
115
|
end
|
100
116
|
end
|
101
117
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: preadly-bulbasaur
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Magno Costa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|