wovnrb 0.1.68 → 0.1.69
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 +9 -3
- data/lib/wovnrb/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: afab139e1be1f8c818b1b106e84fe492a0f89520
|
4
|
+
data.tar.gz: 5484d22f34e056ecd2915e816a6d569270606283
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d4f7a9f1efdac922e1dff2bb87ec5465d60b6e242bf45e90719ed067111be604f470d99a2f5b690f8365b534b04f16408968f5725167a9655d65ae54495a7d0
|
7
|
+
data.tar.gz: 90a7be9c2c2f27d4655273a92d441877f6c4741bed90d65d34a1ddcffbf278b5d75c2795f7a2e6e2230fedb0d58e11846a7c9d56ff95ccfacebd9a63ebb37ae9
|
data/lib/wovnrb.rb
CHANGED
@@ -66,13 +66,19 @@ module Wovnrb
|
|
66
66
|
def add_lang_code(href, pattern, lang, headers)
|
67
67
|
# absolute links
|
68
68
|
new_href = href
|
69
|
-
if href && href =~ /^(https?:)
|
69
|
+
if href && href =~ /^(https?:)?\/\//i
|
70
70
|
uri = URI(href)
|
71
71
|
# only add lang if it's an internal link
|
72
72
|
if uri.host === headers.host
|
73
73
|
case pattern
|
74
74
|
when 'subdomain'
|
75
|
-
|
75
|
+
sub_d = href.match(/\/\/([^\.]*)\./)[1]
|
76
|
+
sub_code = Lang.get_code(sub_d)
|
77
|
+
if sub_code && sub_code.downcase == lang.downcase
|
78
|
+
new_href = href.sub(Regexp.new(lang, 'i'), lang.downcase)
|
79
|
+
else
|
80
|
+
new_href = href.sub(/(\/\/)([^\.]*)/,'\1' + lang.downcase + '.' + '\2' )
|
81
|
+
end
|
76
82
|
when 'query'
|
77
83
|
new_href = href =~ /\?/ ? href + '&wovn=' + lang : href + '?wovn=' + lang
|
78
84
|
else # path
|
@@ -82,7 +88,7 @@ module Wovnrb
|
|
82
88
|
elsif href
|
83
89
|
case pattern
|
84
90
|
when 'subdomain'
|
85
|
-
lang_url = headers.protocol + '://' + lang + '.' + headers.host
|
91
|
+
lang_url = headers.protocol + '://' + lang.downcase + '.' + headers.host
|
86
92
|
if href =~ /^\//
|
87
93
|
new_href = lang_url + href
|
88
94
|
else
|
data/lib/wovnrb/version.rb
CHANGED