devcenter-parser 2.2.5 → 2.2.6

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: b1ecce7a41e0f3665dce79c95b6936d1dd530ed1548055ebe602ede352583192
4
- data.tar.gz: 06a10cc3bb0f7932b79b20bfc481a3408be0996f1e0b8a1ef65d60fe93757dc5
3
+ metadata.gz: 177652c3cda82510b487a9319f2a87c1aeca16b697e56de5cc8690f92d141897
4
+ data.tar.gz: ee6bf49ffb53ad0094092c67179607fef3baecb53c49172d1f63c57a09770670
5
5
  SHA512:
6
- metadata.gz: 6b12389bc38dd0bf4d1125e16d10040121b34f55f10065cb891f04b5f23eae1e5129328a31e5e4fb27a2f278f9f120125caf2e753e59c619aa56e5691659113c
7
- data.tar.gz: 0e27a7fdc0f13a3d1a41d1ae8ddddbc38bb02fb7e7c6d26187f3a77e9994b7c4b7bd7787aa391f76998eae8e567542f93994d22cbadd83a8d74fcdf3644ddff6
6
+ metadata.gz: d7ce23a79c6e9acf16eee9e969b8ded4c58f4e489ca52415b87227eb8c97ac8b93756fbcfa5a5ab49c0f8187da1efab76feb6719c7d500e7567cdeae2dc50375
7
+ data.tar.gz: be81f08407afab73eac94c402b0b59223cc7e9439696131651d9c8aaaead10a7a2228ff9d6ad27943cbf44ed6551d54d5628182e3127f0a436598d9452fd6b17
@@ -94,7 +94,11 @@ module DevcenterParser
94
94
 
95
95
  def self.convert_to_article_links_all_relative_links_with_missing_initial_slashes(doc)
96
96
  doc.css('a').each do |node|
97
- unless node['href'].nil? || node['href'] =~ /\Ahttp|\A\/|\Amailto\:|\A#/
97
+ next if node['href'].nil? || node['href'] =~ /\Ahttp|\A\/|\Amailto\:|\A#/
98
+
99
+ if node['href'].start_with? 'categories/'
100
+ node['href'] = "/#{node['href']}"
101
+ else
98
102
  node['href'] = "/articles/#{node['href']}".gsub('/articles/articles/', '/articles/')
99
103
  end
100
104
  end
@@ -1,3 +1,3 @@
1
1
  module DevcenterParser
2
- VERSION = '2.2.5'.freeze
2
+ VERSION = '2.2.6'.freeze
3
3
  end
@@ -336,13 +336,21 @@ HTML
336
336
  end
337
337
 
338
338
  it 'converts relative links with missing initial slashes to article links' do
339
- ['foo', 'foo/bar', 'foo#bar', '123'].each do |href|
339
+ ['foo', 'foo/bar', 'foo#bar', '123', 'categories'].each do |href|
340
340
  md = "[link](#{href})"
341
341
  html = "<p><a href=\"/articles/#{href}\">link</a></p>"
342
342
  assert_parsing_result md, html
343
343
  end
344
344
  end
345
345
 
346
+ it 'ignores links with missing initial slashes IFF they start with `categories/`' do
347
+ ['categories/foo', 'categories/foo/bar', 'categories/foo#bar', 'categories/123'].each do |href|
348
+ md = "[link](#{href})"
349
+ html = "<p><a href=\"/#{href}\">link</a></p>"
350
+ assert_parsing_result md, html
351
+ end
352
+ end
353
+
346
354
  it 'converts "articles/foo relative links with missing initial slashes to article links' do
347
355
  md = '[link](articles/foo)'
348
356
  html = '<p><a href="/articles/foo">link</a></p>'
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.5
4
+ version: 2.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Heroku
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-31 00:00:00.000000000 Z
11
+ date: 2019-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -119,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  version: '0'
120
120
  requirements: []
121
121
  rubyforge_project:
122
- rubygems_version: 2.7.7
122
+ rubygems_version: 2.7.6
123
123
  signing_key:
124
124
  specification_version: 4
125
125
  summary: Parser for Heroku Dev Center's content