wovnrb 0.1.71 → 0.1.72
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/wovnrb.rb +57 -48
- data/lib/wovnrb/version.rb +1 -1
- data/test/lib/wovnrb_test.rb +195 -147
- metadata +2 -3
- data/wovnrb-0.1.70.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a1a011e4d8bff9e778139c4e77f365df5de6742
|
4
|
+
data.tar.gz: 50c5dbf8bd3b7a4eda18ae59a0a415b907ee8da3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06f5dd0a9c35c0867862c1d96e88a2385aeb0825b5570e7f5936a250755e5d991017ae7c4660d86618d0fda379eb08d4bcdc395ab3b572dd5249dc7e0096c68c
|
7
|
+
data.tar.gz: 150b1708b79dfe172648b53e85e1353e5d0d9635cfc739523702770e284ca5e27a5a52f21bb7fdcdaf9e7d0140c0a3367073df537e43fa783ae544f61cfcb270
|
data/lib/wovnrb.rb
CHANGED
@@ -10,7 +10,7 @@ require 'wovnrb/railtie' if defined?(Rails)
|
|
10
10
|
module Wovnrb
|
11
11
|
|
12
12
|
STORE = Store.new
|
13
|
-
|
13
|
+
|
14
14
|
class Interceptor
|
15
15
|
def initialize(app)
|
16
16
|
@app = app
|
@@ -35,22 +35,22 @@ module Wovnrb
|
|
35
35
|
# pass to application
|
36
36
|
status, res_headers, body = @app.call(headers.request_out)
|
37
37
|
|
38
|
-
if res_headers["Content-Type"] =~ /html
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
38
|
+
if res_headers["Content-Type"] =~ /html/ # && !body[0].nil?
|
39
|
+
puts ""
|
40
|
+
puts ""
|
41
|
+
puts "WOVNRB LOGGING"
|
42
|
+
puts "H-PATHLANG: " + headers.path_lang
|
43
|
+
puts "DEF_LANG: " + STORE.settings['default_lang']
|
44
|
+
puts "WOVNRB LOGGING"
|
45
|
+
puts ""
|
46
|
+
puts ""
|
47
47
|
|
48
48
|
values = STORE.get_values(headers.redis_url)
|
49
49
|
url = {
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
50
|
+
:protocol => headers.protocol,
|
51
|
+
:host => headers.host,
|
52
|
+
:pathname => headers.pathname
|
53
|
+
}
|
54
54
|
body = switch_lang(body, values, url, lang, headers) unless status.to_s =~ /^1|302/
|
55
55
|
|
56
56
|
content_length = 0
|
@@ -64,6 +64,7 @@ module Wovnrb
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def add_lang_code(href, pattern, lang, headers)
|
67
|
+
return href if href =~ /^(#.*)?$/
|
67
68
|
# absolute links
|
68
69
|
new_href = href
|
69
70
|
if href && href =~ /^(https?:)?\/\//i
|
@@ -77,39 +78,47 @@ module Wovnrb
|
|
77
78
|
# only add lang if it's an internal link
|
78
79
|
if uri.host === headers.host
|
79
80
|
case pattern
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
81
|
+
when 'subdomain'
|
82
|
+
sub_d = href.match(/\/\/([^\.]*)\./)[1]
|
83
|
+
sub_code = Lang.get_code(sub_d)
|
84
|
+
if sub_code && sub_code.downcase == lang.downcase
|
85
|
+
new_href = href.sub(Regexp.new(lang, 'i'), lang.downcase)
|
86
|
+
else
|
87
|
+
new_href = href.sub(/(\/\/)([^\.]*)/, '\1' + lang.downcase + '.' + '\2')
|
88
|
+
end
|
89
|
+
when 'query'
|
90
|
+
new_href = href =~ /\?/ ? href + '&wovn=' + lang : href + '?wovn=' + lang
|
91
|
+
else # path
|
92
|
+
new_href = href.sub(/([^\.]*\.[^\/]*)(\/|$)/, '\1/' + lang + '/')
|
92
93
|
end
|
93
94
|
end
|
94
95
|
elsif href
|
95
96
|
case pattern
|
96
|
-
|
97
|
-
|
98
|
-
if href =~ /^\//
|
99
|
-
new_href = lang_url + href
|
100
|
-
else
|
101
|
-
current_dir = headers.pathname.sub(/[^\/]*\.[^\.]{2,6}$/, '')
|
102
|
-
new_href = lang_url + current_dir + href
|
103
|
-
end
|
104
|
-
when 'query'
|
105
|
-
new_href = href =~ /\?/ ? href + '&wovn=' + lang : href + '?wovn=' + lang
|
106
|
-
else # path
|
107
|
-
if href =~ /^\//
|
108
|
-
new_href = '/' + lang + href
|
109
|
-
else
|
97
|
+
when 'subdomain'
|
98
|
+
lang_url = headers.protocol + '://' + lang.downcase + '.' + headers.host
|
110
99
|
current_dir = headers.pathname.sub(/[^\/]*\.[^\.]{2,6}$/, '')
|
111
|
-
|
112
|
-
|
100
|
+
if href =~ /^\.\..*$/
|
101
|
+
# ../path
|
102
|
+
new_href = lang_url + '/' + href.gsub(/^\.\.\//, '')
|
103
|
+
elsif href =~ /^\..*$/
|
104
|
+
# ./path
|
105
|
+
new_href = lang_url + current_dir + '/' + href.gsub(/^\.\//, '')
|
106
|
+
elsif href =~ /^\/.*$/
|
107
|
+
# /path
|
108
|
+
new_href = lang_url + current_dir + href
|
109
|
+
else
|
110
|
+
# path
|
111
|
+
new_href = lang_url + current_dir + '/' + href
|
112
|
+
end
|
113
|
+
when 'query'
|
114
|
+
new_href = href =~ /\?/ ? href + '&wovn=' + lang : href + '?wovn=' + lang
|
115
|
+
else # path
|
116
|
+
if href =~ /^\//
|
117
|
+
new_href = '/' + lang + href
|
118
|
+
else
|
119
|
+
current_dir = headers.pathname.sub(/[^\/]*\.[^\.]{2,6}$/, '')
|
120
|
+
new_href = '/' + lang + current_dir + href
|
121
|
+
end
|
113
122
|
end
|
114
123
|
end
|
115
124
|
new_href
|
@@ -144,7 +153,7 @@ module Wovnrb
|
|
144
153
|
end
|
145
154
|
end
|
146
155
|
# swap meta tag values
|
147
|
-
d.xpath('//meta').select{ |t|
|
156
|
+
d.xpath('//meta').select { |t|
|
148
157
|
(t.get_attribute('name') || t.get_attribute('property') || '') =~ /^(description|keywords|og:title|og:description)$/
|
149
158
|
}.each do |node|
|
150
159
|
node_content = node.get_attribute('content').strip
|
@@ -160,7 +169,7 @@ module Wovnrb
|
|
160
169
|
src = node.to_html.match(/src=['"]([^'"]*)['"]/i)[1]
|
161
170
|
# THIS SRC CORRECTION DOES NOT HANDLE ONE IMPORTANT CASE
|
162
171
|
# 1) "../path/with/ellipse"
|
163
|
-
|
172
|
+
# if this is not an absolute src
|
164
173
|
if src !~ /:\/\//
|
165
174
|
# if this is a path with a leading slash
|
166
175
|
if src =~ /^\//
|
@@ -169,7 +178,7 @@ module Wovnrb
|
|
169
178
|
src = "#{url[:protocol]}://#{url[:host]}#{url[:path]}#{src}"
|
170
179
|
end
|
171
180
|
end
|
172
|
-
|
181
|
+
|
173
182
|
# shouldn't need size check, but for now...
|
174
183
|
if src_index[src] && src_index[src][lang] && src_index[src][lang].size > 0
|
175
184
|
node.attribute('src').value = "#{img_src_prefix}#{src_index[src][lang][0]['data']}"
|
@@ -200,7 +209,7 @@ module Wovnrb
|
|
200
209
|
parent_node.add_child(insert_node)
|
201
210
|
end
|
202
211
|
|
203
|
-
|
212
|
+
|
204
213
|
# INSERT LANGUAGE METALINKS
|
205
214
|
published_langs = get_langs(values)
|
206
215
|
published_langs.each do |l|
|
@@ -216,7 +225,7 @@ module Wovnrb
|
|
216
225
|
(d.at_css('html') || d.at_css('HTML')).set_attribute('lang', lang)
|
217
226
|
end
|
218
227
|
|
219
|
-
output = d.to_html.gsub(/href="([^"]*)"/) {|m| "href=\"#{URI.decode($1)}\""}
|
228
|
+
output = d.to_html.gsub(/href="([^"]*)"/) { |m| "href=\"#{URI.decode($1)}\"" }
|
220
229
|
new_body.push(output)
|
221
230
|
end
|
222
231
|
body.close if body.respond_to?(:close)
|
@@ -229,7 +238,7 @@ module Wovnrb
|
|
229
238
|
langs = Set.new
|
230
239
|
(values['text_vals'] || {}).merge(values['img_vals'] || {}).each do |key, index|
|
231
240
|
index.each do |l, val|
|
232
|
-
|
241
|
+
langs.add(l)
|
233
242
|
end
|
234
243
|
end
|
235
244
|
langs
|
data/lib/wovnrb/version.rb
CHANGED
data/test/lib/wovnrb_test.rb
CHANGED
@@ -19,17 +19,14 @@ class WovnrbTest < Minitest::Test
|
|
19
19
|
# end
|
20
20
|
|
21
21
|
|
22
|
-
|
23
22
|
# def test_switch_lang(body, values, url, lang=STORE.settings['default_lang'], headers)
|
24
23
|
# end
|
25
24
|
|
26
25
|
|
27
|
-
|
28
26
|
# def test_get_langs(values)
|
29
27
|
# end
|
30
28
|
|
31
29
|
|
32
|
-
|
33
30
|
def test_add_lang_code
|
34
31
|
i = Wovnrb::Interceptor.new(get_app)
|
35
32
|
h = Wovnrb::Headers.new(get_env('url' => 'http://favy.tips'), get_settings('url_pattern' => 'subdomain', 'url_pattern_reg' => '^(?<lang>[^.]+).'))
|
@@ -71,150 +68,201 @@ class WovnrbTest < Minitest::Test
|
|
71
68
|
h = Wovnrb::Headers.new(get_env('url' => 'http://favy.tips'), get_settings('url_pattern' => 'subdomain', 'url_pattern_reg' => '^(?<lang>[^.]+).'))
|
72
69
|
assert_equal("http://www.facebook.com/sharer.php?u=http://favy.tips/topics/50&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;t=Gourmet Tofu World: Vegetarian-Friendly Japanese Food is Here!", 'subdomain', 'zh-cht', h))
|
73
70
|
end
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
#
|
133
|
-
|
134
|
-
|
135
|
-
#
|
136
|
-
#
|
137
|
-
#
|
138
|
-
#
|
139
|
-
#
|
140
|
-
#
|
141
|
-
#
|
142
|
-
#
|
143
|
-
#
|
144
|
-
#
|
145
|
-
#
|
146
|
-
#
|
147
|
-
#
|
148
|
-
# headers
|
149
|
-
#
|
150
|
-
#
|
151
|
-
#
|
152
|
-
#
|
153
|
-
#
|
154
|
-
#
|
155
|
-
# headers
|
156
|
-
# headers.expects(:host).returns('google.com')
|
157
|
-
# assert_equal('http://fr.google.com
|
158
|
-
# end
|
159
|
-
#
|
160
|
-
# def
|
161
|
-
# i = Wovnrb::Interceptor.new(get_app)
|
162
|
-
# headers = stub
|
163
|
-
# headers.expects(:
|
164
|
-
#
|
165
|
-
#
|
166
|
-
#
|
167
|
-
#
|
168
|
-
#
|
169
|
-
#
|
170
|
-
#
|
171
|
-
#
|
172
|
-
#
|
173
|
-
#
|
174
|
-
#
|
175
|
-
#
|
176
|
-
#
|
177
|
-
#
|
178
|
-
#
|
179
|
-
#
|
180
|
-
#
|
181
|
-
#
|
182
|
-
#
|
183
|
-
# headers
|
184
|
-
#
|
185
|
-
#
|
186
|
-
#
|
187
|
-
#
|
188
|
-
#
|
189
|
-
#
|
190
|
-
#
|
191
|
-
#
|
192
|
-
#
|
193
|
-
#
|
194
|
-
#
|
195
|
-
#
|
196
|
-
#
|
197
|
-
#
|
198
|
-
#
|
199
|
-
#
|
200
|
-
# i
|
201
|
-
#
|
202
|
-
#
|
203
|
-
#
|
204
|
-
#
|
205
|
-
#
|
206
|
-
#
|
207
|
-
# headers
|
208
|
-
#
|
209
|
-
#
|
210
|
-
#
|
211
|
-
#
|
212
|
-
#
|
213
|
-
#
|
214
|
-
# headers
|
215
|
-
# headers.expects(:
|
216
|
-
#
|
217
|
-
#
|
71
|
+
|
72
|
+
def test_add_lang_code_path_only_with_slash
|
73
|
+
i = Wovnrb::Interceptor.new(get_app)
|
74
|
+
h = Wovnrb::Headers.new(get_env('url' => 'http://favy.tips'), get_settings('url_pattern' => 'subdomain', 'url_pattern_reg' => '^(?<lang>[^.]+).'))
|
75
|
+
assert_equal("http://zh-cht.favy.tips/topics/31", i.add_lang_code("/topics/31", 'subdomain', 'zh-cht', h))
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_add_lang_code_path_only_no_slash
|
79
|
+
i = Wovnrb::Interceptor.new(get_app)
|
80
|
+
h = Wovnrb::Headers.new(get_env('url' => 'http://favy.tips'), get_settings('url_pattern' => 'subdomain', 'url_pattern_reg' => '^(?<lang>[^.]+).'))
|
81
|
+
assert_equal("http://zh-cht.favy.tips/topics/31", i.add_lang_code("topics/31", 'subdomain', 'zh-cht', h))
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_add_lang_code_path_explicit_page_no_slash
|
85
|
+
i = Wovnrb::Interceptor.new(get_app)
|
86
|
+
h = Wovnrb::Headers.new(get_env('url' => 'http://favy.tips'), get_settings('url_pattern' => 'subdomain', 'url_pattern_reg' => '^(?<lang>[^.]+).'))
|
87
|
+
assert_equal("http://zh-cht.favy.tips/topics/31.html", i.add_lang_code("topics/31.html", 'subdomain', 'zh-cht', h))
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_add_lang_code_path_explicit_page_with_slash
|
91
|
+
i = Wovnrb::Interceptor.new(get_app)
|
92
|
+
h = Wovnrb::Headers.new(get_env('url' => 'http://favy.tips'), get_settings('url_pattern' => 'subdomain', 'url_pattern_reg' => '^(?<lang>[^.]+).'))
|
93
|
+
assert_equal("http://zh-cht.favy.tips/topics/31.html", i.add_lang_code("/topics/31.html", 'subdomain', 'zh-cht', h))
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_add_lang_code_no_protocol_with_path_explicit_page
|
97
|
+
i = Wovnrb::Interceptor.new(get_app)
|
98
|
+
h = Wovnrb::Headers.new(get_env('url' => 'http://favy.tips'), get_settings('url_pattern' => 'subdomain', 'url_pattern_reg' => '^(?<lang>[^.]+).'))
|
99
|
+
assert_equal("//www.google.com/topics/31.php", i.add_lang_code("//www.google.com/topics/31.php", 'subdomain', 'zh-cht', h))
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_add_lang_code_protocol_with_path_explicit_page
|
103
|
+
i = Wovnrb::Interceptor.new(get_app)
|
104
|
+
h = Wovnrb::Headers.new(get_env('url' => 'http://favy.tips'), get_settings('url_pattern' => 'subdomain', 'url_pattern_reg' => '^(?<lang>[^.]+).'))
|
105
|
+
assert_equal("http://www.google.com/topics/31.php", i.add_lang_code("http://www.google.com/topics/31.php", 'subdomain', 'zh-cht', h))
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_add_lang_code_relative_path_double_period
|
109
|
+
i = Wovnrb::Interceptor.new(get_app)
|
110
|
+
h = Wovnrb::Headers.new(get_env('url' => 'http://favy.tips'), get_settings('url_pattern' => 'subdomain', 'url_pattern_reg' => '^(?<lang>[^.]+).'))
|
111
|
+
assert_equal("http://zh-cht.favy.tips/topics/31", i.add_lang_code("../topics/31", 'subdomain', 'zh-cht', h))
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_add_lang_code_relative_path_single_period
|
115
|
+
i = Wovnrb::Interceptor.new(get_app)
|
116
|
+
h = Wovnrb::Headers.new(get_env('url' => 'http://favy.tips'), get_settings('url_pattern' => 'subdomain', 'url_pattern_reg' => '^(?<lang>[^.]+).'))
|
117
|
+
assert_equal("http://zh-cht.favy.tips/topics/31", i.add_lang_code("./topics/31", 'subdomain', 'zh-cht', h))
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_add_lang_code_empty_href
|
121
|
+
i = Wovnrb::Interceptor.new(get_app)
|
122
|
+
h = Wovnrb::Headers.new(get_env('url' => 'http://favy.tips'), get_settings('url_pattern' => 'subdomain', 'url_pattern_reg' => '^(?<lang>[^.]+).'))
|
123
|
+
assert_equal("", i.add_lang_code("", 'subdomain', 'zh-cht', h))
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_add_lang_code_hash_href
|
127
|
+
i = Wovnrb::Interceptor.new(get_app)
|
128
|
+
h = Wovnrb::Headers.new(get_env('url' => 'http://favy.tips'), get_settings('url_pattern' => 'subdomain', 'url_pattern_reg' => '^(?<lang>[^.]+).'))
|
129
|
+
assert_equal("#", i.add_lang_code("#", 'subdomain', 'zh-cht', h))
|
130
|
+
end
|
131
|
+
|
132
|
+
# def test_add_lang_code_nil_href
|
133
|
+
# i = Wovnrb::Interceptor.new(get_app)
|
134
|
+
# assert_equal(nil, i.add_lang_code(nil,'path', 'en', nil))
|
135
|
+
# end
|
136
|
+
# def test_add_lang_code_absolute_different_host
|
137
|
+
# i = Wovnrb::Interceptor.new(get_app)
|
138
|
+
# headers = stub
|
139
|
+
# headers.expects(:host).returns('google.com')
|
140
|
+
# assert_equal('http://yahoo.co.jp', i.add_lang_code('http://yahoo.co.jp', 'path', 'fr', headers))
|
141
|
+
# end
|
142
|
+
#
|
143
|
+
# def test_add_lang_code_absolute_subdomain_no_subdomain
|
144
|
+
# i = Wovnrb::Interceptor.new(get_app)
|
145
|
+
# headers = stub
|
146
|
+
# headers.expects(:host).returns('google.com')
|
147
|
+
# assert_equal('http://fr.google.com', i.add_lang_code('http://google.com', 'subdomain', 'fr', headers))
|
148
|
+
# end
|
149
|
+
#
|
150
|
+
# def test_add_lang_code_absolute_subdomain_with_subdomain
|
151
|
+
# i = Wovnrb::Interceptor.new(get_app)
|
152
|
+
# headers = stub
|
153
|
+
# headers.expects(:host).returns('home.google.com')
|
154
|
+
# assert_equal('http://fr.home.google.com', i.add_lang_code('http://home.google.com', 'subdomain', 'fr', headers))
|
155
|
+
# end
|
156
|
+
#
|
157
|
+
# def test_add_lang_code_absolute_query_no_query
|
158
|
+
# i = Wovnrb::Interceptor.new(get_app)
|
159
|
+
# headers = stub
|
160
|
+
# headers.expects(:host).returns('google.com')
|
161
|
+
# assert_equal('http://google.com?wovn=fr', i.add_lang_code('http://google.com', 'query', 'fr', headers))
|
162
|
+
# end
|
163
|
+
#
|
164
|
+
# def test_add_lang_code_absolute_query_with_query
|
165
|
+
# i = Wovnrb::Interceptor.new(get_app)
|
166
|
+
# headers = stub
|
167
|
+
# headers.expects(:host).returns('google.com')
|
168
|
+
# assert_equal('http://google.com?hey=yo&wovn=fr', i.add_lang_code('http://google.com?hey=yo', 'query', 'fr', headers))
|
169
|
+
# end
|
170
|
+
#
|
171
|
+
# def test_add_lang_code_absolute_path_no_pathname
|
172
|
+
# i = Wovnrb::Interceptor.new(get_app)
|
173
|
+
# headers = stub
|
174
|
+
# headers.expects(:host).returns('google.com')
|
175
|
+
# assert_equal('http://google.com/fr/', i.add_lang_code('http://google.com', 'path', 'fr', headers))
|
176
|
+
# end
|
177
|
+
#
|
178
|
+
# def test_add_lang_code_absolute_path_with_pathname
|
179
|
+
# i = Wovnrb::Interceptor.new(get_app)
|
180
|
+
# headers = stub
|
181
|
+
# headers.expects(:host).returns('google.com')
|
182
|
+
# assert_equal('http://google.com/fr/index.html', i.add_lang_code('http://google.com/index.html', 'path', 'fr', headers))
|
183
|
+
# end
|
184
|
+
#
|
185
|
+
# def test_add_lang_code_absolute_path_with_long_pathname
|
186
|
+
# i = Wovnrb::Interceptor.new(get_app)
|
187
|
+
# headers = stub
|
188
|
+
# headers.expects(:host).returns('google.com')
|
189
|
+
# assert_equal('http://google.com/fr/hello/long/path/index.html', i.add_lang_code('http://google.com/hello/long/path/index.html', 'path', 'fr', headers))
|
190
|
+
# end
|
191
|
+
#
|
192
|
+
# def test_add_lang_code_relative_subdomain_leading_slash
|
193
|
+
# i = Wovnrb::Interceptor.new(get_app)
|
194
|
+
# headers = stub
|
195
|
+
# headers.expects(:protocol).returns('http')
|
196
|
+
# headers.expects(:host).returns('google.com')
|
197
|
+
# assert_equal('http://fr.google.com/', i.add_lang_code('/', 'subdomain', 'fr', headers))
|
198
|
+
# end
|
199
|
+
#
|
200
|
+
# def test_add_lang_code_relative_subdomain_leading_slash_filename
|
201
|
+
# i = Wovnrb::Interceptor.new(get_app)
|
202
|
+
# headers = stub
|
203
|
+
# headers.expects(:protocol).returns('http')
|
204
|
+
# headers.expects(:host).returns('google.com')
|
205
|
+
# assert_equal('http://fr.google.com/index.html', i.add_lang_code('/index.html', 'subdomain', 'fr', headers))
|
206
|
+
# end
|
207
|
+
#
|
208
|
+
# def test_add_lang_code_relative_subdomain_no_leading_slash_filename
|
209
|
+
# i = Wovnrb::Interceptor.new(get_app)
|
210
|
+
# headers = stub
|
211
|
+
# headers.expects(:protocol).returns('http')
|
212
|
+
# headers.expects(:host).returns('google.com')
|
213
|
+
# headers.expects(:pathname).returns('/')
|
214
|
+
# assert_equal('http://fr.google.com/index.html', i.add_lang_code('index.html', 'subdomain', 'fr', headers))
|
215
|
+
# end
|
216
|
+
#
|
217
|
+
# def test_add_lang_code_relative_subdomain_dot_filename
|
218
|
+
# i = Wovnrb::Interceptor.new(get_app)
|
219
|
+
# headers = stub
|
220
|
+
# headers.expects(:protocol).returns('http')
|
221
|
+
# headers.expects(:host).returns('google.com')
|
222
|
+
# headers.expects(:pathname).returns('/')
|
223
|
+
# assert_equal('http://fr.google.com/./index.html', i.add_lang_code('./index.html', 'subdomain', 'fr', headers))
|
224
|
+
# end
|
225
|
+
#
|
226
|
+
# def test_add_lang_code_relative_subdomain_two_dots_filename_long_pathname
|
227
|
+
# i = Wovnrb::Interceptor.new(get_app)
|
228
|
+
# headers = stub
|
229
|
+
# headers.expects(:protocol).returns('http')
|
230
|
+
# headers.expects(:host).returns('google.com')
|
231
|
+
# headers.expects(:pathname).returns('/home/hey/index.html')
|
232
|
+
# assert_equal('http://fr.google.com/home/hey/../index.html', i.add_lang_code('../index.html', 'subdomain', 'fr', headers))
|
233
|
+
# end
|
234
|
+
#
|
235
|
+
# def test_add_lang_code_relative_query_with_no_query
|
236
|
+
# i = Wovnrb::Interceptor.new(get_app)
|
237
|
+
# headers = stub
|
238
|
+
# assert_equal('/index.html?wovn=fr', i.add_lang_code('/index.html', 'query', 'fr', headers))
|
239
|
+
# end
|
240
|
+
#
|
241
|
+
# def test_add_lang_code_relative_query_with_query
|
242
|
+
# i = Wovnrb::Interceptor.new(get_app)
|
243
|
+
# headers = stub
|
244
|
+
# assert_equal('/index.html?hey=yo&wovn=fr', i.add_lang_code('/index.html?hey=yo', 'query', 'fr', headers))
|
245
|
+
# end
|
246
|
+
#
|
247
|
+
# def test_add_lang_code_relative_path_with_leading_slash
|
248
|
+
# i = Wovnrb::Interceptor.new(get_app)
|
249
|
+
# headers = stub
|
250
|
+
# assert_equal('/fr/index.html', i.add_lang_code('/index.html', 'path', 'fr', headers))
|
251
|
+
# end
|
252
|
+
#
|
253
|
+
# def test_add_lang_code_relative_path_without_leading_slash_different_pathname
|
254
|
+
# i = Wovnrb::Interceptor.new(get_app)
|
255
|
+
# headers = stub
|
256
|
+
# headers.expects(:pathname).returns('/hello/tab.html')
|
257
|
+
# assert_equal('/fr/hello/index.html', i.add_lang_code('index.html', 'path', 'fr', headers))
|
258
|
+
# end
|
259
|
+
#
|
260
|
+
# def test_add_lang_code_relative_path_without_leading_slash_different_pathname2
|
261
|
+
# i = Wovnrb::Interceptor.new(get_app)
|
262
|
+
# headers = stub
|
263
|
+
# headers.expects(:pathname).returns('/hello/tab.html')
|
264
|
+
# assert_equal('/fr/hello/hey/index.html', i.add_lang_code('hey/index.html', 'path', 'fr', headers))
|
265
|
+
# end
|
218
266
|
|
219
267
|
def get_settings(options={})
|
220
268
|
settings = {}
|
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.
|
4
|
+
version: 0.1.72
|
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-
|
12
|
+
date: 2015-11-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogumbo
|
@@ -251,7 +251,6 @@ files:
|
|
251
251
|
- test/services/url_test.rb
|
252
252
|
- test/test_helper.rb
|
253
253
|
- values/values
|
254
|
-
- wovnrb-0.1.70.gem
|
255
254
|
- wovnrb.gemspec
|
256
255
|
homepage: ''
|
257
256
|
licenses:
|
data/wovnrb-0.1.70.gem
DELETED
Binary file
|