snatch 1.0.5 → 1.0.6
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.
- data/VERSION +1 -1
- data/lib/snatch/clean/html.rb +3 -3
- data/snatch.gemspec +1 -1
- data/spec/snatch/clean/html_spec.rb +8 -0
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.6
|
data/lib/snatch/clean/html.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
class Snatch
|
2
2
|
class Clean
|
3
3
|
class HTML
|
4
|
-
require 'uri'
|
5
|
-
|
6
4
|
module HrefFixMethods
|
7
5
|
# def remove_index_html(a)
|
8
6
|
# a['href'] = a['href'].sub(%r{index\.html?$}, '')
|
@@ -26,7 +24,9 @@ class Snatch
|
|
26
24
|
end
|
27
25
|
|
28
26
|
def prepend_slash(a)
|
29
|
-
|
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
|
30
30
|
end
|
31
31
|
|
32
32
|
def append_slash(a)
|
data/snatch.gemspec
CHANGED
@@ -47,6 +47,14 @@ describe Snatch::Clean::HTML do
|
|
47
47
|
@html.doc.to_xhtml.strip.should == '<a href="/folder/child/index.html"></a>'
|
48
48
|
end
|
49
49
|
|
50
|
+
it 'should preserve parent directories within a URL' do
|
51
|
+
anchor = '<a href="../relative/index.html"></a>'
|
52
|
+
doc = Nokogiri::XML(anchor)
|
53
|
+
@html.doc = doc
|
54
|
+
@html.send(:update)
|
55
|
+
@html.doc.to_xhtml.strip.should == '<a href="../relative/index.html"></a>'
|
56
|
+
end
|
57
|
+
|
50
58
|
it 'should replace an absolute CMS URL with a domainless absolute URL' do
|
51
59
|
anchor = %Q{<a href="http://#{Snatch::MARKETING_SITE}/folder"></a>}
|
52
60
|
fix_node(:replace_absolute, anchor) do |node|
|