snatch 1.0.6 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.6
1
+ 1.0.7
@@ -24,9 +24,8 @@ class Snatch
24
24
  end
25
25
 
26
26
  def prepend_slash(a)
27
- includes_colon = a['href'].include?(':')
28
- starts_with_dots = a['href'][0..1] == '..'
29
- a['href'] = a['href'].sub(%r{^/?}, '/') unless includes_colon || starts_with_dots
27
+ includes_special_chars = !(%w(: .) & a['href'].split(//)).empty?
28
+ a['href'] = a['href'].sub(%r{^/?}, '/') unless includes_special_chars
30
29
  end
31
30
 
32
31
  def append_slash(a)
@@ -36,7 +35,7 @@ class Snatch
36
35
 
37
36
  module SrcFixMethods
38
37
  def replace_absolute(link)
39
- link['src'] = link['src'].sub(%r{(https?)://#{MARKETING_SITE}/}, '/')
38
+ link['src'] = link['src'].sub(%r{^(https?)://#{MARKETING_SITE}/}, '/')
40
39
  end
41
40
 
42
41
  def rewrite_uploads(link)
data/snatch.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{snatch}
8
- s.version = "1.0.6"
8
+ s.version = "1.0.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["James Conroy-Finn"]
@@ -48,11 +48,27 @@ describe Snatch::Clean::HTML do
48
48
  end
49
49
 
50
50
  it 'should preserve parent directories within a URL' do
51
- anchor = '<a href="../relative/index.html"></a>'
51
+ anchor = '<a href="../relative/folder"></a>'
52
52
  doc = Nokogiri::XML(anchor)
53
53
  @html.doc = doc
54
54
  @html.send(:update)
55
- @html.doc.to_xhtml.strip.should == '<a href="../relative/index.html"></a>'
55
+ @html.doc.to_xhtml.strip.should == '<a href="../relative/folder/index.html"></a>'
56
+ end
57
+
58
+ it 'should preserve parent directories within a URL' do
59
+ anchor = '<a href="http://cms.alphasights-002.vm.brightbox.net/advisor/our-guarantee"></a>"'
60
+ doc = Nokogiri::XML(anchor)
61
+ @html.doc = doc
62
+ @html.send(:update)
63
+ @html.doc.to_xhtml.strip.should == '<a href="/advisor/our-guarantee/index.html"></a>'
64
+ end
65
+
66
+ it 'should preserve parent directories within a URL' do
67
+ anchor = '<a href="our-guarantee/index.html"></a>"'
68
+ doc = Nokogiri::XML(anchor)
69
+ @html.doc = doc
70
+ @html.send(:update)
71
+ @html.doc.to_xhtml.strip.should == '<a href="our-guarantee/index.html"></a>'
56
72
  end
57
73
 
58
74
  it 'should replace an absolute CMS URL with a domainless absolute URL' do
@@ -91,8 +107,8 @@ describe Snatch::Clean::HTML do
91
107
 
92
108
  describe "leading slashes and colons" do
93
109
  it 'should append a slash when there is no colon' do
94
- fix_node(:prepend_slash, %Q{<a href="blah/file.txt"></a>}) do |node|
95
- node.should have_href('/blah/file.txt')
110
+ fix_node(:prepend_slash, %Q{<a href="blah/file"></a>}) do |node|
111
+ node.should have_href('/blah/file')
96
112
  end
97
113
  end
98
114
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snatch
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Conroy-Finn