test/devcenter-parser_test.rb in devcenter-parser-2.2.6 vs test/devcenter-parser_test.rb in devcenter-parser-2.2.8
- old
+ new
@@ -359,9 +359,17 @@
md = '[link](articles/foo#bar)'
html = '<p><a href="/articles/foo#bar">link</a></p>'
assert_parsing_result md, html
end
+ it 'adds a link prefix from options for relative dev center links' do
+ md = '[link](foo)'
+ expected = '<p><a href="/ja/articles/foo">link</a></p>'
+
+ result = DevcenterParser.to_html(md, { link_prefix: '/ja/articles' })
+ assert_equal expected.strip, result.strip, "Failed when parsing\n#{md}\n.\n\nExpected:\n#{expected}\n\nActual result:\n#{result}\n\n"
+ end
+
it 'does not alter relative links with initial slashes nor absolute links nor anchor links to the same doc' do
['http://foo.com', 'https://foo.com', '/foo', '/foo/bar', '/foo#bar', '#foo', '/123', 'mailto:foo@foobar.com'].each do |href|
md = "[link](#{href})"
html = "<p><a href=\"#{href}\">link</a></p>"
assert_parsing_result md, html