From 2660548b9001450add529a8a47acbf6e0fa324fb Mon Sep 17 00:00:00 2001 From: Tom Lee Date: Sat, 2 Jan 2021 13:53:23 +0900 Subject: [PATCH] Resolve urlencoded link transformation - Resolves https://github.com/benbalter/jekyll-relative-links/issues/70 --- lib/jekyll-relative-links/generator.rb | 1 + spec/fixtures/site/page with symbols?.md | 6 ++++++ spec/fixtures/site/page.md | 2 ++ spec/jekyll-relative-links/generator_spec.rb | 4 ++++ 4 files changed, 13 insertions(+) create mode 100644 spec/fixtures/site/page with symbols?.md diff --git a/lib/jekyll-relative-links/generator.rb b/lib/jekyll-relative-links/generator.rb index bf4ece6..2a44925 100644 --- a/lib/jekyll-relative-links/generator.rb +++ b/lib/jekyll-relative-links/generator.rb @@ -94,6 +94,7 @@ def markdown_converter end def url_for_path(path) + path = CGI.unescape(path) target = potential_targets.find { |p| p.relative_path.sub(%r!\A/!, "") == path } relative_url(target.url) if target&.url end diff --git a/spec/fixtures/site/page with symbols?.md b/spec/fixtures/site/page with symbols?.md new file mode 100644 index 0000000..63bab04 --- /dev/null +++ b/spec/fixtures/site/page with symbols?.md @@ -0,0 +1,6 @@ +--- +--- + +# Page with Symbols? + +[Page](page.md) diff --git a/spec/fixtures/site/page.md b/spec/fixtures/site/page.md index 263dd70..b481e24 100644 --- a/spec/fixtures/site/page.md +++ b/spec/fixtures/site/page.md @@ -5,6 +5,8 @@ [Another Page](another-page.md) +[Page with Symbols?](page%20with%20symbols%3F.md) + [Page with permalink](page-with-permalink.md) [Page with leading slash](/another-page.md) diff --git a/spec/jekyll-relative-links/generator_spec.rb b/spec/jekyll-relative-links/generator_spec.rb index b2eba10..4bdd240 100644 --- a/spec/jekyll-relative-links/generator_spec.rb +++ b/spec/jekyll-relative-links/generator_spec.rb @@ -51,6 +51,10 @@ expect(page.content).to include("[Another Page](/another-page.html)") end + it "converts relative links with symbols" do + expect(page.content).to include("[Page with Symbols?](/page%20with%20symbols?.html)") + end + it "converts relative links with permalinks" do expect(page.content).to include("[Page with permalink](/page-with-permalink/)") end