-
Notifications
You must be signed in to change notification settings - Fork 266
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
more rubyish #482
more rubyish #482
Conversation
lib/addressable/uri.rb
Outdated
@@ -851,7 +849,8 @@ def initialize(options={}) | |||
self.query_values = options[:query_values] if options[:query_values] | |||
self.fragment = options[:fragment] if options[:fragment] | |||
end | |||
self.to_s | |||
|
|||
to_s # run path validation |
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.
this line took me a bit to figure out, so I figured it was comment worthy. based on the specs, it looks like initialize
leverages the validation of self.path
done in .to_s
. but moving it into .validate
causes other test failures...
Could give this PR a better title? |
for sure. sorry, that got copied over from the other branch. better? (otherwise, open to suggestions) |
end | ||
if port == EMPTY_STR | ||
port = nil | ||
port = nil if port == EMPTY_STR |
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.
Looks like this assignment was moved inside if authority != nil
where it wasn't before.
Not sure it matters (all tests still pass, but we might lack coverage).
Spotted this when looking at the files instead of the diff.
This PR
addressable/lib/addressable/uri.rb
Lines 134 to 148 in 7379545
if authority != nil | |
# The Regexp above doesn't split apart the authority. | |
userinfo = authority[/^([^\[\]]*)@/, 1] | |
if userinfo != nil | |
user = userinfo.strip[/^([^:]*):?/, 1] | |
password = userinfo.strip[/:(.*)$/, 1] | |
end | |
host = authority.sub( | |
/^([^\[\]]*)@/, EMPTY_STR | |
).sub( | |
/:([^:@\[\]]*?)$/, EMPTY_STR | |
) | |
port = authority[/:([^:@\[\]]*?)$/, 1] | |
port = nil if port == EMPTY_STR | |
end |
main
addressable/lib/addressable/uri.rb
Lines 134 to 150 in 8657465
if authority != nil | |
# The Regexp above doesn't split apart the authority. | |
userinfo = authority[/^([^\[\]]*)@/, 1] | |
if userinfo != nil | |
user = userinfo.strip[/^([^:]*):?/, 1] | |
password = userinfo.strip[/:(.*)$/, 1] | |
end | |
host = authority.sub( | |
/^([^\[\]]*)@/, EMPTY_STR | |
).sub( | |
/:([^:@\[\]]*?)$/, EMPTY_STR | |
) | |
port = authority[/:([^:@\[\]]*?)$/, 1] | |
end | |
if port == EMPTY_STR | |
port = nil | |
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.
correct. port is set to nil
on line 133 before the block, so this check only needs to happen if the authority block changes the port value
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.
added a test to ensure proper functionality
7379545
to
af2023a
Compare
af2023a
to
3eec4ff
Compare
rebased. I think these changes still improve code quality / readability, but feel free to close |
while working on #481 I noticed a few things that could be tightened up and be made more Rushish. there should be no functionality changes. Forgive me if this is unwelcomed feedback