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: 014f0ead8b757383f291bc31f15134e1c325032d
4
- data.tar.gz: e3299a0a0b906620a99240065456189bebc08aee
3
+ metadata.gz: 1c7517dcff737c25c17adfa27642bca8ca1cd56e
4
+ data.tar.gz: 577969cc263ffc3fa5ddc98de2acf1a38e27e828
5
5
  SHA512:
6
- metadata.gz: 7b18fbb448369cafdce3789bd9a4c61ec87a198118908fddfdef685c828c65331da6972701d3b713a86abcffde31ce5af0b446ee3abef285aa3df41bfe88affe
7
- data.tar.gz: 37ae03db04175312915da5cd8e9511f3db4f9c56dcebf87d3c3385fb2573b90dd832a73f1cb1a43dec3d3a9b25397a7ffebf4f1bc06898be209fc8a30e14caad
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
@@ -2,7 +2,7 @@ module Bulbasaur
2
2
 
3
3
  module Version
4
4
  MAJOR = 0
5
- MINOR = 5
5
+ MINOR = 6
6
6
  PATCH = 0
7
7
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
8
8
  end
@@ -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 1 item' do
80
- expect(subject.size).to eq 2
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.last[:url]).to eq 'http://somewhere.to/get/the_original_image.jpg?width=400&height=400'
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.first[:url]).to eq 'http://somewhere.to/get/the_original_image.jpg'
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).to include Hash(url: 'http://somewhere.to/get/the_original_image.jpg', alt: nil)
97
- expect(subject).to include Hash(url: 'http://somewhere.to/get/the_original_image.jpg?width=400&height=400', alt: nil)
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.5.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-03 00:00:00.000000000 Z
11
+ date: 2015-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler