wovnrb 3.10.1 → 3.10.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: 59061d2931f333910c0405d78142ffca7317123435456d5524a2b661c3ce6ab8
4
- data.tar.gz: 0cf2cb499d0f2626f8a9785aa2cc70b12d692c83344a602f428e2e13979aecef
3
+ metadata.gz: 9af6b825254ff58bd7415470d312a1618139b2fbfee00e06107cfdb520fcf600
4
+ data.tar.gz: f02b9eff43c8169550eabb34762cc1483c81e214eee79c6fa5b2712450bb24a7
5
5
  SHA512:
6
- metadata.gz: 3d2e73e65e1154eea7d199d548b03937049c58e0de5e46c38cf342f73246f01ae35d976bf4eb0fda31521b821293248274b3c52d8135686198bb5ffb68fe4d45
7
- data.tar.gz: 1993fe20280c540a57728ca5537f71a4a8d579f2d642db57ff9133f5cb8bb31fba15682be529145ad9a218c1b75679a4aa9460b919645b51f41be8bf9f5fb60a
6
+ metadata.gz: 13ae0af14751d63ba2041cf65d8f1810a8cc9350b6ba42885775c0bb2ecddb1691739e66824893f9cb01e2bc91717429722aef6980232a36e97b0bcc02a75232
7
+ data.tar.gz: df18a70cd886965d4c83d3d34c55023ac41fdcc54f7b4bdf6fc2debd4803ef4c1f1569bf8408db27b0ef1199de51964ca3df65b32083f52705d81864953840ff
@@ -42,7 +42,7 @@ module Wovnrb
42
42
 
43
43
  def transform_html
44
44
  replace_snippet
45
- replace_hreflangs
45
+ replace_hreflangs if @store.settings['insert_hreflangs']
46
46
  inject_lang_html_tag
47
47
  translate_canonical_tag if @store.settings['translate_canonical_tag']
48
48
  end
@@ -54,7 +54,7 @@ module Wovnrb
54
54
 
55
55
  def replace_dom(marker)
56
56
  strip_snippet
57
- strip_hreflangs if add_hreflang
57
+ strip_hreflangs if @store.settings['insert_hreflangs']
58
58
 
59
59
  @dom.traverse { |node| transform_node(node, marker) }
60
60
 
@@ -120,10 +120,6 @@ module Wovnrb
120
120
  end
121
121
  end
122
122
 
123
- def add_hreflang
124
- !!(@store && @headers)
125
- end
126
-
127
123
  def inject_lang_html_tag
128
124
  root = @dom.at_css('html')
129
125
  return unless root
@@ -134,7 +130,7 @@ module Wovnrb
134
130
 
135
131
  def replace_hreflangs
136
132
  strip_hreflang_tags
137
- insert_hreflang_tags if @store.settings['insert_hreflangs']
133
+ insert_hreflang_tags
138
134
  end
139
135
 
140
136
  def strip_hreflang_tags
@@ -1,3 +1,3 @@
1
1
  module Wovnrb
2
- VERSION = '3.10.1'.freeze
2
+ VERSION = '3.10.2'.freeze
3
3
  end
@@ -462,6 +462,16 @@ module Wovnrb
462
462
  assert_equal(expected_html, converted_html)
463
463
  end
464
464
 
465
+ test 'build API compatible html - with insert_hreflangs: false - original hreflangs are not removed' do
466
+ settings = default_store_settings
467
+ settings['insert_hreflangs'] = false
468
+ converter = prepare_html_converter('<html><head><link rel="alternate" hreflang="en" href="http://my-site.com/"><link rel="alternate" hreflang="vi" href="http://my-site.com/?wovn=vi"></head><body><a>hello</a></body></html>', settings)
469
+ converted_html, = converter.build_api_compatible_html
470
+
471
+ expected_html = "<html lang=\"en\"><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"https://j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&amp;backend=true&amp;currentLang=en&amp;defaultLang=en&amp;urlPattern=query&amp;langCodeAliases={}&amp;langParamName=wovn&amp;version=WOVN.rb_#{VERSION}\" data-wovnio-type=\"fallback_snippet\"></script><link rel=\"alternate\" hreflang=\"en\" href=\"http://my-site.com/\"><link rel=\"alternate\" hreflang=\"vi\" href=\"http://my-site.com/?wovn=vi\"></head><body><a>hello</a></body></html>"
472
+ assert_equal(expected_html, converted_html)
473
+ end
474
+
465
475
  test 'Transform HTML - with insert_hreflangs: false - hreflangs are not added' do
466
476
  settings = default_store_settings
467
477
  settings['insert_hreflangs'] = false
@@ -472,6 +482,16 @@ module Wovnrb
472
482
  assert_equal(expected_html, translated_html)
473
483
  end
474
484
 
485
+ test 'Transform HTML - with insert_hreflangs: false - original hreflangs are not removed' do
486
+ settings = default_store_settings
487
+ settings['insert_hreflangs'] = false
488
+ converter = prepare_html_converter('<html><head><link rel="alternate" hreflang="en" href="http://my-site.com/"><link rel="alternate" hreflang="vi" href="http://my-site.com/?wovn=vi"></head><body><a>hello</a></body></html>', settings)
489
+ translated_html = converter.build
490
+
491
+ expected_html = "<html lang=\"en\"><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"https://j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&amp;backend=true&amp;currentLang=en&amp;defaultLang=en&amp;urlPattern=query&amp;langCodeAliases={}&amp;langParamName=wovn&amp;version=WOVN.rb_#{VERSION}\" data-wovnio-type=\"fallback_snippet\"></script><link rel=\"alternate\" hreflang=\"en\" href=\"http://my-site.com/\"><link rel=\"alternate\" hreflang=\"vi\" href=\"http://my-site.com/?wovn=vi\"></head><body><a>hello</a></body></html>"
492
+ assert_equal(expected_html, translated_html)
493
+ end
494
+
475
495
  private
476
496
 
477
497
  def prepare_html_converter(input_html, store_options = {})
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: 3.10.1
4
+ version: 3.10.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wovn Technologies, Inc.