devcenter-parser 2.2.9 → 2.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4517ced26a3c0b03ada92affbbaafb25545d0f9bd05ae347a6da9c7567c5b858
4
- data.tar.gz: '05685be056b302fb593c431dc2db6247404f607c382d7e3784cd0cfd267826be'
3
+ metadata.gz: 251949c020f60adc81bbaa2dc0851b5d594486d74620db779cb8030ba8b41c45
4
+ data.tar.gz: e700ec53adb5a531eaaf93f7c70677aabaa6959e801b6fed79bf5ac7f8c559f4
5
5
  SHA512:
6
- metadata.gz: 73e20f5674e995e617b74cf6192032d0ee1d80db4bfdd13246c15b872def1cfb09e27c875cd77ea2ff8d795b1f93787c1d48f0fa7d5ce577e055b9709572af07
7
- data.tar.gz: 69b95cdbd69ff72cb8afaa940b5479730ed2e3781ceccfd22570e1093ba25c8a4c9ab198cb031e2983143016b70b047dc161c6cf4c100f7fa66617e7cb46ea47
6
+ metadata.gz: 9746c03c129900fbc006b96927cfd5f0ffd50169ffc444490e4f219b1a14aa46c8b764d81e21667b0c07a8d6f17cec5277f5da1956070c9b404c3e9af3b96968
7
+ data.tar.gz: d41b9cd6f6248178991096e1c2bbb26fdc1a9dfc6b9f02cb4a1e511a2f36de83b60a44b1e7c6a0218b5983713cd7aadb93d2214b0a5cad7e8c2f923dc59b4814
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- devcenter-parser (2.2.8)
4
+ devcenter-parser (2.2.10)
5
5
  nokogiri (>= 1.7.1)
6
6
  redcarpet (= 3.5.0)
7
7
  sanitize (~> 5.2.1)
@@ -129,7 +129,7 @@ module DevcenterParser
129
129
  end
130
130
 
131
131
  def self.iframe_has_invalid_src?(node)
132
- node.attributes['src'].value !~ /\Ahttps:\/\/player.vimeo.com\//i && node.attributes['src'].value !~ /\Ahttps:\/\/www.youtube.com\/embed/i
132
+ node.attributes['src'].value !~ /https:\/\/player.vimeo.com(.+)(&|\?)dnt=true/i && node.attributes['src'].value !~ /\Ahttps:\/\/www\.youtube-nocookie\.com\/embed/i
133
133
  end
134
134
 
135
135
  def self.iframe?(node)
@@ -72,7 +72,13 @@ class HeaderIdGenerator
72
72
  end
73
73
 
74
74
  def add_default_ids
75
- @nodes_ids.each{ |node, id| @nodes_ids[node] = subheader_id(node.content) }
75
+ @nodes_ids.each do |node, _|
76
+ if node['id'].to_s.empty?
77
+ @nodes_ids[node] = subheader_id(node.content)
78
+ else
79
+ @nodes_ids[node] = node['id']
80
+ end
81
+ end
76
82
  end
77
83
 
78
84
  def subheader_id(content)
@@ -1,3 +1,3 @@
1
1
  module DevcenterParser
2
- VERSION = '2.2.9'.freeze
2
+ VERSION = '2.2.10'.freeze
3
3
  end
@@ -42,11 +42,31 @@ describe 'DevcenterParser' do
42
42
  assert_parsing_result md, html
43
43
  end
44
44
 
45
- it 'allows embedding vimeo videos' do
46
- src = '<iframe src="https://player.vimeo.com/video/61044807?title=0&amp;byline=0&amp;portrait=0&amp;color=a086ee" width="50" height="281" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen=""></iframe>'
45
+ it 'allows embedding vimeo videos when their do-no-track param is set to true' do
46
+ src = '<iframe src="https://player.vimeo.com/video/143343818?api=1&amp;dnt=true&amp;title=foo" width="50" height="281" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen=""></iframe>'
47
47
  assert_parsing_result src, src
48
48
  end
49
49
 
50
+ it 'allows embedding youtube videos from its no-cookies domain' do
51
+ src = '<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/123456ABCDEF" frameborder="0" allowfullscreen=""></iframe>'
52
+ assert_parsing_result src, src
53
+ end
54
+
55
+ it 'removes youtube videos embedded from the with-cookies domain' do
56
+ src = '<iframe width="560" height="315" src="https://www.youtube.com/embed/123456ABCDEF" frameborder="0" allowfullscreen=""></iframe>'
57
+ assert_parsing_result src, ''
58
+ end
59
+
60
+ it 'does not allow embedding vimeo videos when their do-no-track param is set to something different than true' do
61
+ src = '<iframe src="https://player.vimeo.com/video/143343818?api=1&amp;dnt=foo&amp;title=foo" width="50" height="281" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen=""></iframe>'
62
+ assert_parsing_result src, ''
63
+ end
64
+
65
+ it 'does not allow embedding vimeo videos when their do-no-track param is not passed' do
66
+ src = '<iframe src="https://player.vimeo.com/video/143343818?api=1&&amp;title=foo" width="50" height="281" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen=""></iframe>'
67
+ assert_parsing_result src, ''
68
+ end
69
+
50
70
  it 'allows images' do
51
71
  src = '<p><img src="http://nav.heroku.com/images/logos/logo.png" alt="image"></p>'
52
72
  assert_parsing_result src, src
@@ -13,6 +13,12 @@ describe 'HeaderIdGeneratorTest' do
13
13
  assert_id result(html), 'h2', 'foo-bar-header-123'
14
14
  end
15
15
 
16
+ it 'does not replace existing ids' do
17
+ html = '<h2 id="foo">Foo Bar</h2><p>Content</p><h3>Baz</h3>'
18
+ assert_id result(html), 'h2', 'foo'
19
+ assert_id result(html), 'h3', 'baz'
20
+ end
21
+
16
22
  it 'generates ids replacing inner non-alphanum chars with dashes' do
17
23
  ['Foo Bar', 'Foo-Bar', 'Foo#bar', 'Foo##Bar', 'Foo##Bar', '-$Foo##Bar$-'].each do |title|
18
24
  html = "<h2>#{title}</h2>"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devcenter-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.9
4
+ version: 2.2.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Heroku
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-03 00:00:00.000000000 Z
11
+ date: 2020-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri