Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve urlencoded link transformation #71

Merged
merged 1 commit into from
Jan 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/jekyll-relative-links/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions spec/fixtures/site/page with symbols?.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
---

# Page with Symbols?

[Page](page.md)
2 changes: 2 additions & 0 deletions spec/fixtures/site/page.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions spec/jekyll-relative-links/generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down