absolutize 0.0.2 → 0.0.3

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/README.textile CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- h1. Absolutize v0.0.2
2
+ h1. Absolutize v0.0.3
3
3
 
4
4
  h2. Intro
5
5
 
data/lib/absolutize.rb CHANGED
@@ -10,19 +10,20 @@ class Absolutize
10
10
 
11
11
  @options[:remove_anchors] = false
12
12
  @options[:force_escaping] = true
13
-
13
+ @options[:output_debug] = false
14
14
  end
15
15
 
16
16
  def url(new_url)
17
17
  # encode the url if the new url contains spaces but doesn't contain %, i.e isn't already encoded
18
18
  new_url = new_url.split("#").first if new_url.include?"#" and @options[:remove_anchors]
19
+ new_url = new_url.gsub("//", "/") if @options[:force_escaping]
19
20
  new_url = URI.encode(new_url, " <>\{\}|\\\^\[\]`") if not new_url =~ /%/ and @options[:force_escaping]
20
21
  begin
21
22
  URI.join(@base_url, new_url).to_s
22
23
  rescue URI::InvalidURIError => urie
23
- puts "Unable to use URI.join attempting manually"
24
+ puts "Unable to use URI.join attempting manually" if @options[:output_debug]
24
25
  if @base_url =~ /\Ahttp/ and new_url =~ /\A\//
25
- puts "base url starts with htt and new_url is relative to root"
26
+ puts "base url starts with htt and new_url is relative to root" if @options[:output_debug]
26
27
  uri = URI.parse(@base_url)
27
28
  if uri.port
28
29
  "#{uri.scheme}://#{uri.host}:#{uri.port}#{new_url}"
@@ -35,8 +36,6 @@ class Absolutize
35
36
  else
36
37
  raise "Unable to absolutize #{base_url} and #{new_url}"
37
38
  end
38
- end
39
-
40
- ### remove double slashes
39
+ end
41
40
  end
42
41
  end
data/lib/absolutize.rb~ CHANGED
@@ -10,19 +10,20 @@ class Absolutize
10
10
 
11
11
  @options[:remove_anchors] = false
12
12
  @options[:force_escaping] = true
13
-
13
+ @options[:output_debug] = false
14
14
  end
15
15
 
16
16
  def url(new_url)
17
17
  # encode the url if the new url contains spaces but doesn't contain %, i.e isn't already encoded
18
18
  new_url = new_url.split("#").first if new_url.include?"#" and @options[:remove_anchors]
19
+ new_url = new_url.gsub("//", "/") if @options[:force_escaping]
19
20
  new_url = URI.encode(new_url, " <>\{\}|\\\^\[\]`") if not new_url =~ /%/ and @options[:force_escaping]
20
21
  begin
21
22
  URI.join(@base_url, new_url).to_s
22
23
  rescue URI::InvalidURIError => urie
23
- puts "Unable to use URI.join attempting manually"
24
+ puts "Unable to use URI.join attempting manually" if @options[:output_debug]
24
25
  if @base_url =~ /\Ahttp/ and new_url =~ /\A\//
25
- puts "base url starts with htt and new_url is relative to root"
26
+ puts "base url starts with htt and new_url is relative to root" if @options[:output_debug]
26
27
  uri = URI.parse(@base_url)
27
28
  if uri.port
28
29
  "#{uri.scheme}://#{uri.host}:#{uri.port}#{new_url}"
@@ -36,7 +37,5 @@ class Absolutize
36
37
  raise "Unable to absolutize #{base_url} and #{new_url}"
37
38
  end
38
39
  end
39
-
40
- ### remove double slashes
41
40
  end
42
41
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: absolutize
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Stewart McKee