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 +1 -1
- data/lib/snatch/clean/html.rb +3 -4
- data/snatch.gemspec +1 -1
- data/spec/snatch/clean/html_spec.rb +20 -4
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.7
|
data/lib/snatch/clean/html.rb
CHANGED
@@ -24,9 +24,8 @@ class Snatch
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def prepend_slash(a)
|
27
|
-
|
28
|
-
|
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
@@ -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/
|
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
|
95
|
-
node.should have_href('/blah/file
|
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
|
|