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

Urls starting with / handled as absolute urls from the root #62

Merged
merged 3 commits into from Jun 29, 2020

Conversation

krichardsson
Copy link
Contributor

@krichardsson krichardsson commented Jun 29, 2020

This pull requests makes absolute urls behave the same way as on github. A url that starts with a / should be interpreted as an absolute url, starting from the root.

Example:
if we have the file foo/bar.md, containing the link [my absolute link](/foo/bar.md), the generated html should point to /foo/bar/


View rendered spec/fixtures/site/page.md
View rendered spec/fixtures/site/subdir/page.md

@welcome
Copy link

welcome bot commented Jun 29, 2020

Welcome! Congrats on your first pull request to Jekyll Relative Links. If you haven't already, please be sure to check out the contributing guidelines.

@krichardsson
Copy link
Contributor Author

Also found an old issue, #47

relative_path.sub!(%r!\A/!, "")
absolute_path = File.expand_path(relative_path, url_base)
base = is_absolute ? "" : url_base
absolute_path = File.expand_path(relative_path, base)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to put this in path_from_root rather than passing it around?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point!

Copy link
Owner

@benbalter benbalter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this @krichardsson!

@benbalter benbalter merged commit 8fcee0b into benbalter:master Jun 29, 2020
@welcome
Copy link

welcome bot commented Jun 29, 2020

Congrats on getting your first pull request to Jekyll Relative Links merged! Without amazing humans like you submitting pull requests, we couldn’t run this project. You rock! 🎉

If you're interested in tackling another bug or feature, take a look at the open issues, especially those labeled help wanted.

@benbalter benbalter mentioned this pull request Jun 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants