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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/devcenter-parser.rb +1 -1
- data/lib/devcenter-parser/header_id_generator.rb +7 -1
- data/lib/devcenter-parser/version.rb +1 -1
- data/test/devcenter-parser_test.rb +22 -2
- data/test/header_id_generator_test.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 251949c020f60adc81bbaa2dc0851b5d594486d74620db779cb8030ba8b41c45
|
4
|
+
data.tar.gz: e700ec53adb5a531eaaf93f7c70677aabaa6959e801b6fed79bf5ac7f8c559f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9746c03c129900fbc006b96927cfd5f0ffd50169ffc444490e4f219b1a14aa46c8b764d81e21667b0c07a8d6f17cec5277f5da1956070c9b404c3e9af3b96968
|
7
|
+
data.tar.gz: d41b9cd6f6248178991096e1c2bbb26fdc1a9dfc6b9f02cb4a1e511a2f36de83b60a44b1e7c6a0218b5983713cd7aadb93d2214b0a5cad7e8c2f923dc59b4814
|
data/Gemfile.lock
CHANGED
data/lib/devcenter-parser.rb
CHANGED
@@ -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 !~
|
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
|
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)
|
@@ -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/
|
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&dnt=true&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&dnt=foo&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&&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.
|
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-
|
11
|
+
date: 2020-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|