snatch 1.0.5 → 1.0.6

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.5
1
+ 1.0.6
@@ -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
- a['href'] = a['href'].sub(%r{^/?}, '/') unless a['href'].include?(':')
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
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{snatch}
8
- s.version = "1.0.5"
8
+ s.version = "1.0.6"
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"]
@@ -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|
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.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Conroy-Finn