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

fix: move protocol "clean" after merge of parsedOptions #1965

Merged
merged 2 commits into from
Feb 3, 2025

Conversation

mmoriani
Copy link
Contributor

@mmoriani mmoriani commented Jan 31, 2025

With this commit the removal of the “:”, for the protocol passed in connect options, was moved before the merge of parsedOptions.

parsedOptions.protocol = parsedOptions.protocol?.replace(
	/:$/,
	'',
) as MqttProtocol

opts = { ...parsedOptions, ...opts }

Previously, if someone passed as a protocol “mqtts:” (Protocol returned by the URL interface) this was “cleaned” by removing the “:”.

By moving the replace after the options merge, a backward compatibility is maintained for those, like me, who find themselves having to update deps in codes where the protocol was passed in by taking the value from the URL interface.

I know that the documentation as protocol values does not accept “:”, but so far it has accepted them anyway and fixed if url is passed.

I also think that if the URL interface returns the protocol in this way, it may be convenient to pass it directly without having to modify it.

@mmoriani mmoriani changed the title Move protocol "clean" after merge of parsedOptions perf: Move protocol "clean" after merge of parsedOptions Jan 31, 2025
@robertsLando robertsLando changed the title perf: Move protocol "clean" after merge of parsedOptions fix: move protocol "clean" after merge of parsedOptions Feb 3, 2025
Copy link
Member

@robertsLando robertsLando left a comment

Choose a reason for hiding this comment

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

Could you submit a quick test to cover this please?

Copy link

codecov bot commented Feb 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.15%. Comparing base (ad78551) to head (bc91aae).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1965   +/-   ##
=======================================
  Coverage   81.15%   81.15%           
=======================================
  Files          24       24           
  Lines        1470     1470           
  Branches      349      349           
=======================================
  Hits         1193     1193           
  Misses        193      193           
  Partials       84       84           
Flag Coverage Δ
unittests 81.15% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@robertsLando robertsLando enabled auto-merge (squash) February 3, 2025 09:11
@robertsLando robertsLando merged commit 1c19ca0 into mqttjs:main Feb 3, 2025
6 of 7 checks passed
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.

2 participants