-
Notifications
You must be signed in to change notification settings - Fork 116
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
Fixed error when the site.github config key is set, but site.github.url is not #43
Conversation
@@ -59,7 +59,8 @@ def redirect_prefix(site) | |||
end | |||
|
|||
def config_github_url(site) | |||
site.config.fetch('github', Hash.new).fetch('url', nil) | |||
config_github = site.config.fetch('github', Hash.new) | |||
config_github.respond_to?('fetch') ? config_github.fetch('url', nil) : nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just out of curiosity, do you think it would be cleaner to write this with an inline if
statement?
config_github.fetch('url', nil) if config_github.respond_to?('fetch')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, duh, don't mind me—you need the nil
return value here. 😊
Sorry, I think my suggestion actually would return nil
if config_github.respond_to?('fetch')
returned false
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, your suggestion works too. I don't have a preference, but I don't do much Ruby, so not sure which one is considered more idiomatic 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe @parkr would know...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd probably write:
def config_github_url(site)
github_config = site.config['github']
github_config['url'] if github_config.is_a?(Hash)
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@parkr done
Wow, that was fast. Thanks for opening this, @akoeplinger! |
9f102d0
to
e6c6e87
Compare
Fixes #42