Skip to content

Refactor PusherOptions to improve URI construction and logging format - #6

Merged
AbdoPrDZ merged 1 commit into
AbdoPrDZ:mainfrom
blackwolf3342:blackwolf3342/fix-options-loop
Oct 24, 2025
Merged

Refactor PusherOptions to improve URI construction and logging format#6
AbdoPrDZ merged 1 commit into
AbdoPrDZ:mainfrom
blackwolf3342:blackwolf3342/fix-options-loop

Conversation

@blackwolf3342

@blackwolf3342 blackwolf3342 commented Oct 21, 2025

Copy link
Copy Markdown
Contributor

Copying @padit69 PR #4 to be able release that.

This PR refactors the PusherOptions class in /lib/src/options.dart with the following improvements:

URI Construction Changes

  • Added proper error handling by constructing a fallback hostUri in the catch block when host parsing fails
  • Simplified URI building logic by ensuring hostUri is always initialized before use, eliminating complex null-checking ternary operators
  • Replaced uri.port with hostUri.port and changed port check from port == 0 to using the hasPort property for better semantics
  • Updated query parameter check from hostUri?.query.isNotEmpty == true to the cleaner hostUri.hasQuery property

@blackwolf3342

Copy link
Copy Markdown
Contributor Author

@AbdoPrDZ

@AbdoPrDZ
AbdoPrDZ requested a review from Copilot October 24, 2025 13:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the PusherOptions class to improve URI construction reliability and code formatting. The changes ensure that hostUri is always properly initialized even when host parsing fails, and simplify the URI building logic by removing complex null-checking patterns in favor of cleaner property checks.

Key Changes:

  • Added fallback URI construction in the catch block to guarantee hostUri is never null
  • Replaced null-safe operators and ternary expressions with direct property access using hasPort and hasQuery
  • Improved code formatting with consistent multi-line syntax and trailing commas

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@AbdoPrDZ

Copy link
Copy Markdown
Owner

Hey!
Thanks a lot for your contribution 😊
Could you please remove the IDE formatting changes so it’s easier to review your actual edits?

Really appreciate your help!

@AbdoPrDZ

Copy link
Copy Markdown
Owner

@blackwolf3342

@blackwolf3342
blackwolf3342 force-pushed the blackwolf3342/fix-options-loop branch from f4167a0 to fd8fd1e Compare October 24, 2025 13:56
@blackwolf3342

Copy link
Copy Markdown
Contributor Author

@AbdoPrDZ updated PR

@AbdoPrDZ
AbdoPrDZ merged commit 6f519f0 into AbdoPrDZ:main Oct 24, 2025
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.

3 participants