-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
Fix current url_options without a port (default port) #43
Conversation
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.
Thank you for your PR @albus522
@@ -20,7 +20,8 @@ def compose(source_keys, destination_key, **) | |||
def current_host | |||
opts = url_options || {} | |||
url = "#{opts[:protocol]}#{opts[:host]}" | |||
url + ":#{opts[:port]}" if opts[:port] | |||
url += ":#{opts[:port]}" if opts[:port] |
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.
What about using <<
instead?
url += ":#{opts[:port]}" if opts[:port] | |
url << ":#{opts[:port]}" if opts[:port] |
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.
That is not a good idea while you still support ruby 2.7. Ruby 3 updated the frozen string literal setting to account for dynamic string literals, but ruby 2.7 will error can't modify frozen String
for anyone that has turned that on globally because you have it enabled.
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.
Sorry for the late reply.
+=
duplicates the string (you can make a test with object_id
)
You can setup an unfrozen string when you are preparing it:
url = +"#{opts[:protocol]}#{opts[:host]}"
Also: please rebase your PR, the tests should work then. |
1f5f910
to
8e4b680
Compare
Rebased |
If no port is specified on
ActiveStorage::Current.url_options
current_host
would returnnil
instead of"http://example.com"