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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a9c98db709cfa34ea061b420304c70354a65f99e
4
- data.tar.gz: e8deb759f20bbb4bf407e179cbe42be8a63aa996
3
+ metadata.gz: afab139e1be1f8c818b1b106e84fe492a0f89520
4
+ data.tar.gz: 5484d22f34e056ecd2915e816a6d569270606283
5
5
  SHA512:
6
- metadata.gz: 5cbf2bf0e473cb5b89a776b0c3ce6e3ddcb57d65b76231309123c8bbfbaf7297e35e9fd29e6ff8f7ea478f5ea11a33ee3b688fdf3d754298867571173b104306
7
- data.tar.gz: 2cc3e6363b308b12df4bee0fda3b147b9f5ab2c52336346d4cecc46e745219fd057b3ffcda2ad680eaf012a2829787ab88a110db2a6686f78aefa4c31e9b422d
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?:)\/\//i
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
- new_href = href.sub(/(\/\/)([^\.]*)/,'\1' + lang + '.' + '\2' )
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
@@ -1,3 +1,3 @@
1
1
  module Wovnrb
2
- VERSION = "0.1.68"
2
+ VERSION = "0.1.69"
3
3
  end
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.68
4
+ version: 0.1.69
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Sandford