wovnrb 0.1.70 → 0.1.71

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4776a67c2ad218f974c0f0b4f3c0b832c90a5a09
4
- data.tar.gz: cc37e82b4c978abe5ce1ea7ac395a9d185998dca
3
+ metadata.gz: 6de41f16ba0cd217fe246d63968cb01e5c2a6ee1
4
+ data.tar.gz: 5d86fa885bc7ccca860d417be1313c26ab82e637
5
5
  SHA512:
6
- metadata.gz: 96e887e480911dc72395cd152840e9762dc1ae0037e10c34934c3cd4c2a55dafc39b5da62c4bd8dab77f9e91de1a973df8a562b0dfb0157f113f0492fff3e036
7
- data.tar.gz: 41c97ebc38bf12c946f9ad0046fe916b8d37caf217a9ae9981bab406b8d0da768bbf2075a7b07cfc30994c4501cc52006ddae896097b9b3b0d68405df1246225
6
+ metadata.gz: 49c9a83d6d90562cdb15100feda10bb56b5611d471a8dcc14b8a109ec64de02a9336550e9a79d420235e0374b6dc0896d112970e56db7ab6bd52df91a9564987
7
+ data.tar.gz: e54a6893605f5d36c5e439f82f4742405d085e788144f46763f2391caca76913cd648b68f44bb6f7fe304e5f0eea3e319a6d6d86aa8fb70df376313bb5200ed7
data/.gitignore CHANGED
@@ -18,3 +18,4 @@
18
18
  *.a
19
19
  *.swp
20
20
  mkmf.log
21
+ .idea/
data/lib/wovnrb.rb CHANGED
@@ -67,7 +67,13 @@ module Wovnrb
67
67
  # absolute links
68
68
  new_href = href
69
69
  if href && href =~ /^(https?:)?\/\//i
70
- uri = URI(href)
70
+ # in the future, perhaps validate url rather than using begin rescue
71
+ # "#{url =~ /\// ? 'http:' : ''}#{url}" =~ URI::regexp
72
+ begin
73
+ uri = URI(href)
74
+ rescue
75
+ return new_href
76
+ end
71
77
  # only add lang if it's an internal link
72
78
  if uri.host === headers.host
73
79
  case pattern
@@ -1,3 +1,3 @@
1
1
  module Wovnrb
2
- VERSION = "0.1.70"
2
+ VERSION = "0.1.71"
3
3
  end
@@ -5,52 +5,82 @@ require 'pry'
5
5
 
6
6
  class WovnrbTest < Minitest::Test
7
7
 
8
+ def get_app
9
+ end
10
+
11
+
8
12
  def test_initialize
9
13
  i = Wovnrb::Interceptor.new(get_app)
10
14
  refute_nil(i)
11
15
  end
12
16
 
17
+
13
18
  # def test_call(env)
14
19
  # end
15
20
 
21
+
22
+
16
23
  # def test_switch_lang(body, values, url, lang=STORE.settings['default_lang'], headers)
17
24
  # end
18
25
 
26
+
27
+
19
28
  # def test_get_langs(values)
20
29
  # end
21
30
 
22
- def get_app()
31
+
32
+
33
+ def test_add_lang_code
34
+ i = Wovnrb::Interceptor.new(get_app)
35
+ h = Wovnrb::Headers.new(get_env('url' => 'http://favy.tips'), get_settings('url_pattern' => 'subdomain', 'url_pattern_reg' => '^(?<lang>[^.]+).'))
36
+ assert_equal("http://www.facebook.com", i.add_lang_code("http://www.facebook.com", 'subdomain', 'zh-cht', h))
37
+ end
38
+
39
+ def test_add_lang_code_trad_chinese
40
+ i = Wovnrb::Interceptor.new(get_app)
41
+ h = Wovnrb::Headers.new(get_env('url' => 'http://favy.tips'), get_settings('url_pattern' => 'subdomain', 'url_pattern_reg' => '^(?<lang>[^.]+).'))
42
+ assert_equal("http://zh-cht.favy.tips/topics/31", i.add_lang_code("http://favy.tips/topics/31", 'subdomain', 'zh-cht', h))
43
+ end
44
+
45
+ def test_add_lang_code_trad_chinese_2
46
+ i = Wovnrb::Interceptor.new(get_app)
47
+ h = Wovnrb::Headers.new(get_env('url' => 'http://zh-cht.favy.tips'), get_settings('url_pattern' => 'subdomain', 'url_pattern_reg' => '^(?<lang>[^.]+).'))
48
+ assert_equal("http://zh-cht.favy.tips/topics/31", i.add_lang_code("/topics/31", 'subdomain', 'zh-cht', h))
49
+ end
50
+
51
+ def test_add_lang_code_trad_chinese_lang_in_link_already
52
+ i = Wovnrb::Interceptor.new(get_app)
53
+ h = Wovnrb::Headers.new(get_env('url' => 'http://zh-cht.favy.tips'), get_settings('url_pattern' => 'subdomain', 'url_pattern_reg' => '^(?<lang>[^.]+).'))
54
+ assert_equal("http://zh-cht.favy.tips/topics/31", i.add_lang_code("http://zh-cht.favy.tips/topics/31", 'subdomain', 'zh-cht', h))
55
+ end
56
+
57
+ def test_add_lang_code_no_protocol
58
+ i = Wovnrb::Interceptor.new(get_app)
59
+ h = Wovnrb::Headers.new(get_env('url' => 'https://zh-cht.google.com'), get_settings('url_pattern' => 'subdomain', 'url_pattern_reg' => '^(?<lang>[^.]+).'))
60
+ assert_equal("//zh-cht.google.com", i.add_lang_code("//google.com", 'subdomain', 'zh-cht', h))
61
+ end
62
+
63
+ def test_add_lang_code_no_protocol_2
64
+ i = Wovnrb::Interceptor.new(get_app)
65
+ h = Wovnrb::Headers.new(get_env('url' => 'https://zh-cht.favy.tips'), get_settings('url_pattern' => 'subdomain', 'url_pattern_reg' => '^(?<lang>[^.]+).'))
66
+ assert_equal("//google.com", i.add_lang_code("//google.com", 'subdomain', 'zh-cht', h))
67
+ end
68
+
69
+ def test_add_lang_code_invalid_url
70
+ i = Wovnrb::Interceptor.new(get_app)
71
+ h = Wovnrb::Headers.new(get_env('url' => 'http://favy.tips'), get_settings('url_pattern' => 'subdomain', 'url_pattern_reg' => '^(?<lang>[^.]+).'))
72
+ assert_equal("http://www.facebook.com/sharer.php?u=http://favy.tips/topics/50&amp;amp;t=Gourmet Tofu World: Vegetarian-Friendly Japanese Food is Here!", i.add_lang_code("http://www.facebook.com/sharer.php?u=http://favy.tips/topics/50&amp;amp;t=Gourmet Tofu World: Vegetarian-Friendly Japanese Food is Here!", 'subdomain', 'zh-cht', h))
23
73
  end
74
+ #//url
75
+ #/path
76
+ #path
77
+ #../path
78
+ #path.html
79
+ #/path.html
80
+ #//url/path.php
81
+ #http://url/path.php
82
+ #./path
24
83
 
25
- def test_add_lang_code_trad_chinese
26
- i = Wovnrb::Interceptor.new(get_app)
27
- h = Wovnrb::Headers.new(get_env('url' => 'http://favy.tips'), get_settings('url_pattern' => 'subdomain', 'url_pattern_reg' => '^(?<lang>[^.]+).'))
28
- assert_equal("http://zh-cht.favy.tips/topics/31", i.add_lang_code("http://favy.tips/topics/31", 'subdomain', 'zh-cht', h))
29
- end
30
-
31
- def test_add_lang_code_trad_chinese_2
32
- i = Wovnrb::Interceptor.new(get_app)
33
- h = Wovnrb::Headers.new(get_env('url' => 'http://zh-cht.favy.tips'), get_settings('url_pattern' => 'subdomain', 'url_pattern_reg' => '^(?<lang>[^.]+).'))
34
- assert_equal("http://zh-cht.favy.tips/topics/31", i.add_lang_code("/topics/31", 'subdomain', 'zh-cht', h))
35
- end
36
-
37
- def test_add_lang_code_trad_chinese_lang_in_link_already
38
- i = Wovnrb::Interceptor.new(get_app)
39
- h = Wovnrb::Headers.new(get_env('url' => 'http://zh-cht.favy.tips'), get_settings('url_pattern' => 'subdomain', 'url_pattern_reg' => '^(?<lang>[^.]+).'))
40
- assert_equal("http://zh-cht.favy.tips/topics/31", i.add_lang_code("http://zh-cht.favy.tips/topics/31", 'subdomain', 'zh-cht', h))
41
- end
42
-
43
- def test_add_lang_code_no_protocol
44
- i = Wovnrb::Interceptor.new(get_app)
45
- h = Wovnrb::Headers.new(get_env('url' => 'https://zh-cht.google.com'), get_settings('url_pattern' => 'subdomain', 'url_pattern_reg' => '^(?<lang>[^.]+).'))
46
- assert_equal("//zh-cht.google.com", i.add_lang_code("//google.com", 'subdomain', 'zh-cht', h))
47
- end
48
-
49
- def test_add_lang_code_no_protocol_2
50
- i = Wovnrb::Interceptor.new(get_app)
51
- h = Wovnrb::Headers.new(get_env('url' => 'https://zh-cht.favy.tips'), get_settings('url_pattern' => 'subdomain', 'url_pattern_reg' => '^(?<lang>[^.]+).'))
52
- assert_equal("//google.com", i.add_lang_code("//google.com", 'subdomain', 'zh-cht', h))
53
- end
54
84
  # def test_add_lang_code_nil_href
55
85
  # i = Wovnrb::Interceptor.new(get_app)
56
86
  # assert_equal(nil, i.add_lang_code(nil,'path', 'en', nil))
data/wovnrb-0.1.70.gem ADDED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wovnrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.70
4
+ version: 0.1.71
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Sandford
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-11-10 00:00:00.000000000 Z
12
+ date: 2015-11-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogumbo
@@ -251,6 +251,7 @@ files:
251
251
  - test/services/url_test.rb
252
252
  - test/test_helper.rb
253
253
  - values/values
254
+ - wovnrb-0.1.70.gem
254
255
  - wovnrb.gemspec
255
256
  homepage: ''
256
257
  licenses: