wovnrb 3.7.1 → 3.7.2

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
  SHA256:
3
- metadata.gz: f8da9741562e23b433e622ef091da98042d6eab8dbe621cdfaa7d59bf29e58c6
4
- data.tar.gz: 5a6e81693935de46ea0e7eaa3fac7d6eab40a3f1bb8e4fff594adc76699f5023
3
+ metadata.gz: 6cc4b57cbbcb73d7c80599b43c3c5cc2cf942bd2488d6d53ed80cbc33810dc32
4
+ data.tar.gz: 075a4767449cfa394036400ab377be8659939f59c4229d9192b2042b9eabd65d
5
5
  SHA512:
6
- metadata.gz: 3ad1400b4c55e9989ab1c251330f5c3659ef0830a02a7e689f87e4ca248e23d9e40b65d9912a0745070151509c7243807981af7b2e985a7a973875e90ed68b71
7
- data.tar.gz: c323c7912fc06eb004ab4b0ce3d130c6a7fa01b65d23472091dda391ab77f1fe4a37ac4a3edccf40462063fd4af1747530fc889306bfd0995564120a5f0b77f3
6
+ metadata.gz: d5952288b10b0d86e39ff6496bccc0a9c5d51ff876d0f41f07fb1b7b33cc9cab0792d2a1f7c97477849f4dedb20cfada495e6498255a987825c478f305e076f8
7
+ data.tar.gz: 323f2b3d50b221b67831c43b9a70e2d595bfd3d7a86f4325cbfbdb2fb700ce0cd48da7952f6a5950064d5766de34b743abd1d9f14dc3764677d61a6787a1e113
@@ -44,7 +44,11 @@ module Wovnrb
44
44
  rp = Regexp.new("(^|(//))#{lang_code}\\.", 'i')
45
45
  uri.sub(rp, '\1')
46
46
  when 'path'
47
- uri.sub(%r{/#{lang_code}(/|$)}, '/')
47
+ # ^(.*://|//)? 1: schema (optional) like https://
48
+ # ([^/]*/)? 2: host (optional) like wovn.io, with trailing '/' (mandatory)
49
+ # (/|$) 3: path or end-of-string
50
+ lang_code_pattern = %r{^(.*://|//)?([^/]*/)?#{lang_code}(/|$)}
51
+ uri.sub(lang_code_pattern, '\1\2')
48
52
  else
49
53
  raise RuntimeError("Invalid URL pattern: #{@store.settings['url_pattern']}")
50
54
  end
@@ -1,3 +1,3 @@
1
1
  module Wovnrb
2
- VERSION = '3.7.1'.freeze
2
+ VERSION = '3.7.2'.freeze
3
3
  end
@@ -876,17 +876,20 @@ module Wovnrb
876
876
  def test_remove_lang_path
877
877
  settings = Wovnrb.get_settings
878
878
  store = Wovnrb.get_store(settings)
879
- url_lang_switcher = UrlLanguageSwitcher.new(store)
879
+ sut = UrlLanguageSwitcher.new(store)
880
880
 
881
881
  keys = Wovnrb::Lang::LANG.keys
882
882
  assert_equal(77, keys.size)
883
883
 
884
884
  keys.each do |key|
885
- uri_without_scheme = url_lang_switcher.remove_lang_from_uri_component("wovn.io/#{key}", key)
886
- assert_equal('wovn.io/', uri_without_scheme)
887
-
888
- uri_with_scheme = url_lang_switcher.remove_lang_from_uri_component("https://wovn.io/#{key}/", key)
889
- assert_equal('https://wovn.io/', uri_with_scheme)
885
+ assert_equal('/', sut.remove_lang_from_uri_component("/#{key}", key))
886
+ assert_equal("/dir/#{key}/page.html", sut.remove_lang_from_uri_component("/#{key}/dir/#{key}/page.html", key))
887
+ assert_equal('?query', sut.remove_lang_from_uri_component('?query', key))
888
+ assert_equal('wovn.io/', sut.remove_lang_from_uri_component("wovn.io/#{key}", key))
889
+ assert_equal("wovn.io/dir/#{key}/page.html", sut.remove_lang_from_uri_component("wovn.io/#{key}/dir/#{key}/page.html", key))
890
+ assert_equal("wovn.io:5000/dir/#{key}/page.html", sut.remove_lang_from_uri_component("wovn.io:5000/#{key}/dir/#{key}/page.html", key))
891
+ assert_equal('https://wovn.io/', sut.remove_lang_from_uri_component("https://wovn.io/#{key}/", key))
892
+ assert_equal("https://wovn.io/dir/#{key}/page.html", sut.remove_lang_from_uri_component("https://wovn.io/#{key}/dir/#{key}/page.html", key))
890
893
  end
891
894
  end
892
895
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wovnrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.7.1
4
+ version: 3.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wovn Technologies, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-09 00:00:00.000000000 Z
11
+ date: 2022-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport