content_urls 0.1.9 → 0.1.10

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MjEzNmE4NjIyMWNiNjg2MmNlMjZkZWIxMzY5ODg3YjczZDI1OWI4OQ==
4
+ MjFiODIwNDEyYzA0NDI4NzQ3NDEyNTYyYjUwMTI4ZDEyYzVkYTU0MA==
5
5
  data.tar.gz: !binary |-
6
- Y2E3YTdhOTk1YzNhZDQ5MmMyNDFmYTQ5MGI5ZThiOWRkZDNiY2QzMQ==
6
+ YWQzOGFjY2Y1ZTZhNmEwMzNmYmIxZWY3MjVlZDM1NzQ2MzM5YjY4Mw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- Y2RjNDFmMGU1MjljZDg1YzAyODI4MTcwNDQ3Y2RmY2RmMzk1ZTQ4NDM2NGQ0
10
- YmE0M2I0OTBiNmRhODdhY2NjMjMzYmYwNWVhODJkYzAxN2JiNDc5ZDFlNWQx
11
- MGZkOWRhNzNiZDgyMzM0YjUzMjIyZWQ2ODY5MTEzOThiZjIxZjU=
9
+ M2I0MTQwNTk4MDVmMjg3MDg5ZDI4NmU3NWFkODk2OTljY2ViNGZiNGQ4MDgy
10
+ NzZmYzZiODIwYmM1MzhhYzZkZTVhZDZiOTRlZjBmZmNjYWVhMTgxODAzNTNh
11
+ NmNmN2ZmNTgwNTgxN2JkMDRjMWMzZTkyYmNhYjNkZWNhMjI5OWY=
12
12
  data.tar.gz: !binary |-
13
- ODRjMzFlNjdiNmVmZjA0OWViNzQ3NWQwY2U2YTM2MzFhZmNiODJkNGFmMTBj
14
- MTVkNmM1YTI0NDZhZTBiYjUyNjgwNTZhZDM3ZmQ2ZGVlYTZjODFlNzY3YTA2
15
- OTg0Y2I1YTQwYzMwMWVlZDliY2NmNjQ3OGZmZGNlODY2N2MwYzc=
13
+ ZTA2YzQyYTMxYTM2ZTA4Mzk4YTJiYmQ3Y2IyNWFlNGY4Nzg1NTgxYzcwNjRj
14
+ ZWFiMTY0OWFmMzAyN2VmYTc0MTdlY2E3YjYwMTU1MmMxNDhiNjcxMWQ2MDAy
15
+ OGEwZTVmZDdjOWRiNmI4ZmM1YmM3NWY3MWUzM2MwZGU0OTMzOWI=
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "content_urls"
8
- s.version = "0.1.9"
8
+ s.version = "0.1.10"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Dennis Sutch"]
@@ -94,7 +94,7 @@ class ContentUrls
94
94
  #
95
95
  def self.rewrite_each_url(content, type, &block)
96
96
  if (parser = get_parser(type))
97
- parser.rewrite_each_url(content) do |url|
97
+ content = parser.rewrite_each_url(content) do |url|
98
98
  replacement = yield url
99
99
  (replacement.nil? ? url : replacement)
100
100
  end
@@ -111,7 +111,7 @@ class ContentUrls
111
111
  def self.to_absolute(url, base_url)
112
112
  return nil if url.nil?
113
113
 
114
- url = URI.encode(URI.decode(url.to_s.gsub(/#[a-zA-Z0-9_-]*$/,''))) # remove anchor
114
+ url = URI.encode(URI.decode(url.to_s.gsub(/#[a-zA-Z0-9\s_-]*$/,''))) # remove anchor
115
115
  absolute = URI(base_url).merge(url)
116
116
  absolute.path = '/' if absolute.path.empty?
117
117
  absolute.to_s
@@ -2,7 +2,7 @@ class ContentUrls
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
- PATCH = 9
5
+ PATCH = 10
6
6
  BUILD = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
@@ -81,3 +81,26 @@ BASE_SAMPLE
81
81
  urls[0].should eq 'http://www.example.com/about.html'
82
82
  end
83
83
  end
84
+
85
+ describe ContentUrls do
86
+ it "should not change absolute URLs when requested to make absolute URLs from relative URLs" do
87
+
88
+ html_sample =<<HTML_SAMPLE
89
+ <html>
90
+ <head>
91
+ <title>HTML Sample</title>
92
+ </head>
93
+ <body>
94
+ <h1>HTML Sample</h1>
95
+ <a href='http://www.example.com/about.html'>about</a>
96
+ </body>
97
+ </html>
98
+ HTML_SAMPLE
99
+
100
+ rewritten = ContentUrls.rewrite_each_url(html_sample, 'text/html') {|u|
101
+ 'http://example.org/about.php'
102
+ }
103
+ urls = ContentUrls.urls(rewritten, 'text/html')
104
+ urls[0].should eq 'http://example.org/about.php'
105
+ end
106
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: content_urls
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dennis Sutch