wovnrb 0.2.19 → 0.2.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/wovnrb/headers.rb +6 -6
- data/lib/wovnrb/version.rb +1 -1
- data/test/lib/headers_test.rb +54 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f30155825513a841ed260d157839f2d5d9ccc302
|
4
|
+
data.tar.gz: fbd5f149deef651dcf1d400150b7175f9e2a537e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de46ce6ada35bb48385e91844f6baffbb4fb0f2a170621b530c9ca7a70485c42fb40db09a080707f200cec7b0cf73d66a9e9e7758480434613aa0ea381626e77
|
7
|
+
data.tar.gz: a028a8fe2562dabf36d601a85cbc5db979c50ddb41a3d2d5d443ce3225740f7293d3b3de1344832e72c5eda0f6a62f831742ea1d4c705c62303bd64f4b65dfd5
|
data/lib/wovnrb/headers.rb
CHANGED
@@ -210,20 +210,20 @@ module Wovnrb
|
|
210
210
|
def out(headers)
|
211
211
|
r = Regexp.new("//" + @host)
|
212
212
|
lang_code = Store.instance.settings['custom_lang_aliases'][self.lang_code] || self.lang_code
|
213
|
-
if headers.has_key?("Location") && headers["Location"] =~ r
|
213
|
+
if lang_code != @settings['default_lang'] && headers.has_key?("Location") && headers["Location"] =~ r
|
214
214
|
case @settings['url_pattern']
|
215
215
|
when 'query'
|
216
|
-
if headers[
|
217
|
-
headers[
|
216
|
+
if headers['Location'] =~ /\?/
|
217
|
+
headers['Location'] += "&"
|
218
218
|
else
|
219
|
-
headers[
|
219
|
+
headers['Location'] += "?"
|
220
220
|
end
|
221
221
|
headers['Location'] += "wovn=#{lang_code}"
|
222
222
|
when 'subdomain'
|
223
|
-
headers[
|
223
|
+
headers['Location'] = headers["Location"].sub(/\/\/([^.]+)/, '//' + lang_code + '.\1')
|
224
224
|
#when 'path'
|
225
225
|
else
|
226
|
-
headers[
|
226
|
+
headers['Location'] = headers['Location'].sub(/(\/\/[^\/]+)/, '\1/' + lang_code)
|
227
227
|
end
|
228
228
|
end
|
229
229
|
headers
|
data/lib/wovnrb/version.rb
CHANGED
data/test/lib/headers_test.rb
CHANGED
@@ -245,6 +245,60 @@ module Wovnrb
|
|
245
245
|
assert_equal('http://staging-ja.wovn.io/test', h.out(headers)['Location'])
|
246
246
|
end
|
247
247
|
|
248
|
+
def test_out_original_lang_with_subdomain_url_pattern
|
249
|
+
h = Wovnrb::Headers.new(
|
250
|
+
Wovnrb.get_env(
|
251
|
+
'SERVER_NAME' => 'wovn.io',
|
252
|
+
'REQUEST_URI' => '/test',
|
253
|
+
'HTTP_REFERER' => 'http://wovn.io/test',
|
254
|
+
),
|
255
|
+
Wovnrb.get_settings(
|
256
|
+
'url_pattern' => 'subdomain',
|
257
|
+
'url_pattern_reg' => '^(?<lang>[^.]+).',
|
258
|
+
),
|
259
|
+
)
|
260
|
+
headers = h.request_out(h.lang_code)
|
261
|
+
assert_equal('http://wovn.io/test', headers['HTTP_REFERER'])
|
262
|
+
headers['Location'] = headers['HTTP_REFERER']
|
263
|
+
assert_equal('http://wovn.io/test', h.out(headers)['Location'])
|
264
|
+
end
|
265
|
+
|
266
|
+
def test_out_original_lang_with_path_url_pattern
|
267
|
+
h = Wovnrb::Headers.new(
|
268
|
+
Wovnrb.get_env(
|
269
|
+
'SERVER_NAME' => 'wovn.io',
|
270
|
+
'REQUEST_URI' => '/test',
|
271
|
+
'HTTP_REFERER' => 'http://wovn.io/test',
|
272
|
+
),
|
273
|
+
Wovnrb.get_settings(
|
274
|
+
'url_pattern' => 'path',
|
275
|
+
'url_pattern_reg' => '/(?<lang>[^/.?]+)',
|
276
|
+
),
|
277
|
+
)
|
278
|
+
headers = h.request_out(h.lang_code)
|
279
|
+
assert_equal('http://wovn.io/test', headers['HTTP_REFERER'])
|
280
|
+
headers['Location'] = headers['HTTP_REFERER']
|
281
|
+
assert_equal('http://wovn.io/test', h.out(headers)['Location'])
|
282
|
+
end
|
283
|
+
|
284
|
+
def test_out_original_lang_with_query_url_pattern
|
285
|
+
h = Wovnrb::Headers.new(
|
286
|
+
Wovnrb.get_env(
|
287
|
+
'SERVER_NAME' => 'wovn.io',
|
288
|
+
'REQUEST_URI' => '/test',
|
289
|
+
'HTTP_REFERER' => 'http://wovn.io/test',
|
290
|
+
),
|
291
|
+
Wovnrb.get_settings(
|
292
|
+
'url_pattern' => 'query',
|
293
|
+
'url_pattern_reg' => '((\\?.*&)|\\?)wovn=(?<lang>[^&]+)(&|$)',
|
294
|
+
),
|
295
|
+
)
|
296
|
+
headers = h.request_out(h.lang_code)
|
297
|
+
assert_equal('http://wovn.io/test', headers['HTTP_REFERER'])
|
298
|
+
headers['Location'] = headers['HTTP_REFERER']
|
299
|
+
assert_equal('http://wovn.io/test', h.out(headers)['Location'])
|
300
|
+
end
|
301
|
+
|
248
302
|
def test_out_with_wovn_target_lang_header_using_subdomain
|
249
303
|
h = Wovnrb::Headers.new(
|
250
304
|
Wovnrb.get_env(
|
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.2.
|
4
|
+
version: 0.2.20
|
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: 2017-
|
12
|
+
date: 2017-06-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogumbo
|